update method
Method update updates entry on database
Implementation
@override
Future<dynamic> update(T? item) async {
final values = converter.decodeTable(item);
where({schema.primaryKey: values.remove(schema.primaryKey)});
/// Remove any relation attributes
for (final relation in relations) {
if (relation is HasMany) {
values.remove(relation.dao!.schema.table);
} else if (relation is BelongsTo) {
values.remove(relation.dao!.type);
} else if (relation is HasOne) {
values.remove(relation.dao!.schema.table);
}
}
final builder = SqlBuilder.update(
schema.table!,
values as Map<String, Object?>,
where: _whereQuery,
whereArgs: _whereArgs,
);
final completer = Completer<dynamic>()
..complete(database!.rawUpdate(builder.sql, builder.arguments));
if (isLogger!) Logger.update(type, completer.future, builder);
return await completer.future.whenComplete(clear);
}