updateManyFromMap method

void updateManyFromMap(
  1. Map<String, Object> docMap, {
  2. int? index,
})

Same as updateMany but in Map format. Schema: { updateMany : { "filter" :

Implementation

void updateManyFromMap(Map<String, Object> docMap, {int? index}) {
  var filterMap = docMap[bulkFilter];
  if (filterMap is! Map<String, Object>) {
    throw MongoDartError('The "$bulkFilter" key of the '
        '"$bulkUpdateMany" element '
        '${index == null ? '' : 'at index $index '}must '
        'contain a Map');
  }
  if (docMap[bulkUpdate] is! Map<String, Object> &&
      docMap[bulkUpdate] is! List<Map<String, dynamic>>) {
    throw MongoDartError('The "$bulkUpdate" key of the '
        '"$bulkUpdateMany" element '
        '${index == null ? '' : 'at index $index '}must '
        'contain a Map or a pipeline (List<Map>)');
  }
  if (docMap[bulkUpsert] != null && docMap[bulkUpsert] is! bool) {
    throw MongoDartError('The "$bulkUpsert" key of the '
        '"$bulkUpdateMany" element at index $index must '
        'contain a bool');
  }
  if (docMap[bulkCollation] != null &&
      docMap[bulkCollation] is! CollationOptions &&
      docMap[bulkCollation] is! Map<String, dynamic>) {
    throw MongoDartError('The "$bulkCollation" key of the '
        '"$bulkUpdateMany" element '
        '${index == null ? '' : 'at index $index '}must '
        'contain a CollationOptions element or a Map representation '
        'of a collation');
  }
  if (docMap[bulkArrayFilters] != null &&
      docMap[bulkArrayFilters] is! List<Map<String, dynamic>>) {
    throw MongoDartError('The "$bulkArrayFilters" key of the '
        '"$bulkUpdateMany" element '
        '${index == null ? '' : 'at index $index '}must '
        'contain a List<Map<String, dynamic>> Object');
  }
  if (docMap[bulkHint] != null && docMap[bulkHint] is! String) {
    throw MongoDartError('The "$bulkHint" key of the '
        '"$bulkUpdateMany" element '
        '${index == null ? '' : 'at index $index '}must '
        'contain a String');
  }
  if (docMap[bulkHintDocument] != null &&
      docMap[bulkHintDocument] is! Map<String, Object>) {
    throw MongoDartError('The "$bulkHintDocument" key of the '
        '"$bulkUpdateMany" element '
        '${index == null ? '' : 'at index $index '}must '
        'contain a Map');
  }
  updateMany(UpdateManyStatement(filterMap, docMap[bulkUpdate] as Object,
      upsert: docMap[bulkUpsert] as bool?,
      collation: docMap[bulkCollation] is Map<String, dynamic>
          ? CollationOptions.fromMap(
              docMap[bulkCollation] as Map<String, Object>)
          : docMap[bulkCollation] as CollationOptions?,
      arrayFilters: docMap[bulkArrayFilters] as List?,
      hint: docMap[bulkHint] as String?,
      hintDocument: docMap[bulkHintDocument] as Map<String, Object>?));
}