updateSomeColumnsOf<T> method
Updates one or more columns of the entity T.
columnsToUpadate: names of the columns to update, in the order they appear at the start ofvalues.whereColumns: names of the columns appearing in the WHERE clause, in the order they appear at the end ofvalues.values: values forcolumnsToUpadatefollowed by values forwhereColumns.whereMcop: operator used to join multiple WHERE conditions:'AND'(default) or'OR'.
Example:
final ok = await DataAccess.instance.updateSomeColumnsOf<Person>(
['salary', 'married', 'year'],
['name'],
[9000000, true, 45, 'Alpha'],
);
Implementation
Future<bool> updateSomeColumnsOf<T>(
List<String> columnsToUpadate,
List<String> whereColumns,
List<Object> values, {
String whereMcop = 'AND',
}) async {
final SqlExecutor executor = await _executor();
return _guard('updateSomeColumnsOf', false, () async {
final String op = joinOperator(whereMcop);
final int affected = await executor.change(
'UPDATE ${quoteIdentifier(_tableFor<T>())} '
'SET ${preparedColumns(columnsToUpadate, ',')} '
'WHERE ${preparedColumns(whereColumns, op)}',
toSqlValues(values),
);
return affected > 0;
});
}