deleteManyFromMap method

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

Same as deleteMany but in Map format: Schema: { deleteMany : { "filter" :

Implementation

void deleteManyFromMap(Map<String, Object> docMap, {int? index}) {
  var contentMap = docMap[bulkFilter];
  if (contentMap is! Map<String, Object>) {
    throw MongoDartError('The "$bulkFilter" key of the '
        '"$bulkDeleteMany" element '
        '${index == null ? '' : 'at index $index '}must contain a Map');
  }
  if (docMap[bulkCollation] != null &&
      docMap[bulkCollation] is! CollationOptions &&
      docMap[bulkCollation] is! Map<String, dynamic>) {
    throw MongoDartError('The "$bulkCollation" key of the '
        '"$bulkDeleteMany" element '
        '${index == null ? '' : 'at index $index '}must '
        'contain a CollationOptions element or a Map representation '
        'of a collation');
  }
  if (docMap[bulkHint] != null && docMap[bulkHint] is! String) {
    throw MongoDartError('The "$bulkHint" key of the '
        '"$bulkDeleteMany" 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 '
        '"$bulkDeleteMany" element '
        '${index == null ? '' : 'at index $index '}must '
        'contain a Map');
  }
  deleteMany(DeleteManyStatement(contentMap,
      collation: docMap[bulkCollation] is Map
          ? CollationOptions.fromMap(
              docMap[bulkCollation] as Map<String, Object>)
          : docMap[bulkCollation] as CollationOptions?,
      hint: docMap[bulkHint] as String?,
      hintDocument: docMap[bulkHintDocument] as Map<String, Object>?));
}