delete static method

Future<void> delete(
  1. dynamic keys, {
  2. dynamic lazy = false,
})

Deletes a setting with the specified key or keys.

Parameters:

  • keys: A unique key or list of keys for the setting(s) to delete. Keys are case-insensitive and will be searched in lowercase.
  • lazy: Whether to delete the setting(s) in a lazy transaction. Defaults to false.

Implementation

static Future<void> delete(dynamic keys, {lazy = false}) async {
  final db = await DB.instance();

  List<String> listOfKeys = keys is String ? [keys] : keys;

  final lcKeys = listOfKeys.map((String key) => key.toLowerCase()).toList();

  if (lazy) {
    db.writeTxn(() async => db.kVs.deleteAllByKey(lcKeys));
  } else {
    await db.writeTxn(() async => await db.kVs.deleteAllByKey(lcKeys));
  }

  _cache.removeWhere((key, value) => lcKeys.contains(key));
}