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,
}) async {
  DVSqlRecordAdapter._refuseEverything(where, 'update');
  int changed = 0;
  for (final Map<String, Object?> record in _in(collection)) {
    if (where.matches(record)) {
      record.addAll(changes);
      changed++;
    }
  }
  return changed;
}