updateMany method

Future<List> updateMany({
  1. required dynamic filter,
  2. required UpdateOperator update,
})

Update all documents in the collection according to the specified arguments.

Implementation

Future<List> updateMany(
    {required filter, required UpdateOperator update}) async {
  assert(filter is Map<String, dynamic> || filter is LogicalQueryOperator);

  if (filter is Map<String, dynamic>) {
    // convert 'QuerySelector' into map, too
    filter.forEach((dynamic key, value) {
      if (value is QueryOperator) {
        filter[key] = value.values;
      }
    });
  }
  if (filter is LogicalQueryOperator) {
    filter = filter.values;
  }

  List results = await (FlutterMongoRealm.updateDocuments(
    collectionName: this.collectionName,
    databaseName: this.databaseName,
    filter: BsonDocument(filter).toJson(),
    update: BsonDocument(update.values).toJson(),
  ));

  return results;
}