insertOrUpdateList method
Implementation
@override
Future<List<TEntity>?> insertOrUpdateList(Iterable<TEntity> items) async {
final db = await dbContext.database;
List<TEntity>? result;
List<TEntity> updatedItems = <TEntity>[];
await db.transaction((txn) async {
var batch = txn.batch();
for (var element in items) {
if (element.id == null) {
element = element.copyWith(id: const Uuid().v4()) as TEntity;
}
element = element.updateDates() as TEntity;
updatedItems.add(element);
batch.insert(element.meta.tableName, element.toMap(),
conflictAlgorithm: ConflictAlgorithm.replace);
}
result = await _finishBatch(batch, updatedItems);
});
return result;
}