update method
Future<int>
update({
- required Filter where(
- TMeta t
- TEntity? entity,
- Map<
ColumnDefinition< columnValues(IEntity, dynamic> , dynamic>- TMeta t
- bool? useIsolate,
Implementation
@override
Future<int> update({
required Filter Function(TMeta t) where,
TEntity? entity,
Map<ColumnDefinition, dynamic> Function(TMeta t)? columnValues,
final bool? useIsolate,
}) async {
var query = where(t)
.filters
.where((element) => element.column?.name == 'id')
.toList();
if (query.isNotEmpty == true) {
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 = res![t.createdAt.name];
}
}
entity = (entity ?? mType).updateDates(createdAt: createdAt) as TEntity;
final update = columnValues != null
? entity.toStorageJson(columnValues: columnValues(t))
: entity.toMap();
await write(key: query[0].value, value: update);
return 1;
}
return 0;
}