update method
Future<int>
update({
- required Filter where(
- TMeta t
- TEntity? entity,
- Map<
ColumnDefinition< columnValues(IEntity, dynamic> , dynamic>- TMeta t
- bool? useIsolate,
inherited
Implementation
@override
Future<int> update({
required Filter Function(TMeta t) where,
TEntity? entity,
Map<ColumnDefinition, dynamic> Function(TMeta t)? columnValues,
final bool? useIsolate,
}) async {
assert(entity != null || columnValues != null);
final db = await dbContext.database;
final formattedQuery = await whereString(where, useIsolate);
var createdAt = entity?.createdAt;
if (entity == null) {
final res = await firstWhereOrNullMap(
where: where, columns: (t) => [t.createdAt]);
if (res?.containsKey(t.createdAt.name) == true) {
createdAt = DateTime.parse(res![t.createdAt.name]);
}
}
entity = (entity ?? mType).updateDates(createdAt: createdAt) as TEntity;
final update = columnValues != null
? entity.toStorageJson(columnValues: columnValues(t))
: entity.toDb();
return await db.update(
t.tableName,
update,
where: formattedQuery.filter,
whereArgs: formattedQuery.whereArgs,
);
}