updateWholeObject method
Updates every column of an entity instance except the primary key.
Example:
final ok = await DataAccess.instance.updateWholeObject(
Person(18, 'M2Sir'),
['name'],
['Alpha'],
);
Implementation
Future<bool> updateWholeObject(
Object newObject,
List<String> whereColumns,
List<Object> values, {
String whereMcop = 'AND',
}) async {
int affected = 0;
await (await db).transaction((txn) async {
try {
affected = await txn.update(
newObject.runtimeType.toString(),
mapToUse((newObject as dynamic).toMap() as Map<String, dynamic>),
where: _preparedColumns(whereColumns, whereMcop),
whereArgs: _checkForBoolAndDateTime(values),
);
} catch (e, s) {
debugPrint('updateWholeObject failed: $e\n$s');
}
});
return affected > 0;
}