save method
Updates an existing model in the database.
Implementation
Future<T> save(T model) async {
if (!model.exists) {
return await create(model);
}
final data = <String, dynamic>{...model.toMap()};
if (model.timestamps) {
data['updated_at'] = DateTime.now().toUtc();
}
await QueryBuilder(_tableName, _executor)
.where('id', '=', model.id)
.update(data);
// Return a fresh copy from DB
return await findOrFail(model.id);
}