insertOrUpdateList method
Implementation
@override
Future<List<TEntity>?> insertOrUpdateList(
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) {
updatedItems.add(element.entity as TEntity);
batch.insert(element.entity.meta.tableName, element.map,
conflictAlgorithm: ConflictAlgorithm.replace);
}
result = await _finishBatch(batch, updatedItems);
});
return result;
}