update method

  1. @override
Future<int> update(
  1. String collection,
  2. Map<String, Object?> changes, {
  3. required DVFilter where,
})
override

Applies changes to the records where picks, and answers how many.

An optimistic write names the version it read in where; nought changed is the conflict.

Implementation

@override
Future<int> update(
  String collection,
  Map<String, Object?> changes, {
  required DVFilter where,
}) {
  _refuseEverything(where, 'update');
  final List<Object?> params = changes.values.map(_value).toList();
  final String assignments = changes.keys
      .map((String k) => '${_name(k)} = ?')
      .join(', ');
  return _execute(
    'UPDATE ${_collection(collection)} SET $assignments${_where(where, params)}',
    params,
  );
}