generateUniqueIntKeys method

  1. @override
Future<List<int>> generateUniqueIntKeys(
  1. String store,
  2. int count
)

Generate unique int keys.

Implementation

@override
Future<List<int>> generateUniqueIntKeys(String store, int count) async {
  var keys = <int>[];
  var txn = _idbDatabase.transaction([
    idbEntryStore,
    idbInfoStore,
  ], idbModeReadOnly);
  var infoStore = txn.objectStore(idbInfoStore);
  var infoKey = _storeLastIdKey(store);
  var lastId = (await infoStore.getObject(infoKey) as int?) ?? 0;

  for (var i = 0; i < count; i++) {
    lastId++;
    keys.add(lastId);
  }
  await txn.completed;
  return keys;
}