insertList method
Implementation
@override
Future<List<TEntity>?> insertList(
Iterable<TEntity> items, {
final bool? useIsolate,
}) async {
final db = await dbContext.database;
List<TEntity>? result;
List<TEntity> updatedItems = <TEntity>[];
final spawnIsolate = useIsolate ?? useIsolateDefault;
final response = !spawnIsolate
? wInsertOrUpdateList(items)
: await compute(wInsertOrUpdateList, items);
await db.transaction((txn) async {
var batch = txn.batch();
for (var element in response) {
batch.insert(element.entity.meta.tableName, element.map,
conflictAlgorithm: ConflictAlgorithm.abort);
updatedItems.add(element.entity as TEntity);
}
result = await _finishBatch(batch, updatedItems);
});
return result;
}