saveMany method

  1. @override
Future<int> saveMany({
  1. required List<T> entities,
  2. Database? database,
  3. int? chunk,
  4. required MergeMode mergeMode,
  5. SaveOptions? saveOptions,
})
override

Implementation

@override
Future<int> saveMany(
    {required List<T> entities,
    Database? database,
    int? chunk,
    required MergeMode mergeMode,
    SaveOptions? saveOptions}) async {
  final Database db = database != null ? database : this.database;

  if (entities.isEmpty) {
    return 1;
  }

  final queue = Queue(parallel: chunk ?? 500);

  entities.forEach((T entity) {
    queue.add(() => saveOne(
        entity: entity,
        database: db,
        mergeMode: mergeMode,
        saveOptions: saveOptions));
  });

  await queue.onComplete;

  return 1;
}