---
title: "MongoCollectionDeleteMany"
language: "en"
type: "Symbol"
summary: "MongoCollectionDeleteMany[MongoCollection[...], filter] deletes one or more documents that match the filter filter."
canonical_url: "https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionDeleteMany.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "MongoLink Operations"
    link: "https://reference.wolfram.com/language/MongoLink/guide/MongoLinkOperations.en.md"
related_functions: 
  - 
    title: "MongoCollection"
    link: "https://reference.wolfram.com/language/MongoLink/ref/MongoCollection.en.md"
  - 
    title: "MongoCollectionDeleteOne"
    link: "https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionDeleteOne.en.md"
  - 
    title: "MongoCollectionUpdateOne"
    link: "https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionUpdateOne.en.md"
  - 
    title: "MongoCollectionUpdateMany"
    link: "https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionUpdateMany.en.md"
  - 
    title: "MongoWriteConcern"
    link: "https://reference.wolfram.com/language/MongoLink/ref/MongoWriteConcern.en.md"
related_tutorials: 
  - 
    title: "MongoLink Introduction"
    link: "https://reference.wolfram.com/language/MongoLink/tutorial/MongoLinkSimpleTutorial.en.md"
---
[EXPERIMENTAL]

## MongoLink\`

# MongoCollectionDeleteMany

MongoCollectionDeleteMany[MongoCollection[…], filter] deletes one or more documents that match the filter filter.

## Details and Options

* To use ``MongoCollectionDeleteMany``, you first need to load [*MongoLink*](https://reference.wolfram.com/language/MongoLink/guide/MongoLinkOperations.en.md) using ``Needs["MongoLink`"]``.

* ``filter`` is an [`Association`](https://reference.wolfram.com/language/ref/Association.en.md). ``filter`` uses the same the same syntax as the first argument ``query`` to ``MongoCollectionFind``. The list of available query selectors can be found in the [MongoDB documentation](https://docs.mongodb.com/manual/reference/operator/query/#query-selectors).

* The following option is supported:

"WriteConcern" 	[`Automatic`](https://reference.wolfram.com/language/ref/Automatic.en.md)	the write concern to use.

* ``"WriteConcern"`` can either be [`Automatic`](https://reference.wolfram.com/language/ref/Automatic.en.md), or a ``MongoWriteConcern`` object.

* ``MongoCollectionDeleteMany`` corresponds to [db.collection.deleteMany()](https://docs.mongodb.com/manual/reference/method/db.collection.deleteMany/#db.collection.deleteMany)[](https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/#)in the MongoDB manual.

---

## Examples (2)

### Basic Examples (1)

```wl
In[1]:= Needs["MongoLink`"]
```

Connect to a client:

```wl
In[2]:= client = MongoConnect[]

Out[2]= MongoLink`MongoClient[MongoLink`PackageScope`clientMLE[1]]
```

Connect to a the "WolframTestCollection" collection in the "WolframTestDB" database:

```wl
In[3]:= coll = client["WolframTestDB"]["WolframTestCollection"]

Out[3]=
MongoLink`MongoCollection[MongoLink`PackageScope`collectionMLE[1], "WolframTestDB", 
 "WolframTestCollection", MongoLink`MongoClient[MongoLink`PackageScope`clientMLE[1]]]
```

Delete all of the documents that match the filter <\|"age"->11\|>:

```wl
In[4]:= MongoCollectionDeleteMany[coll, <|"age" -> 11|>]

Out[4]= <|"Acknowledged" -> True, "DeletedCount" -> 2|>
```

### Options (1)

#### "WriteConcern" (1)

```wl
In[1]:= Needs["MongoLink`"]
```

Connect to a client:

```wl
In[2]:= client = OpenMongoConnection[]

Out[2]= MongoLink`MongoClient[MongoLink`PackageScope`clientMLE[11]]
```

Connect to a the "WolframTestCollection" collection in the "WolframTestDB" database:

```wl
In[3]:= coll = client["WolframTestDB"]["WolframTestCollection"]

Out[3]=
MongoLink`MongoCollection[MongoLink`PackageScope`collectionMLE[8], "WolframTestDB", 
 "WolframTestCollection", MongoLink`MongoClient[MongoLink`PackageScope`clientMLE[11]]]
```

Delete all of the documents that match the filter <\|"age"->11\|>:

```wl
In[4]:= MongoCollectionDeleteMany[coll, <|"age" -> 11|>, "WriteConcern" -> Automatic]

Out[4]= Dataset[<>]
```

## See Also

* [MongoCollection](https://reference.wolfram.com/language/MongoLink/ref/MongoCollection.en.md)
* [MongoCollectionDeleteOne](https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionDeleteOne.en.md)
* [MongoCollectionUpdateOne](https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionUpdateOne.en.md)
* [MongoCollectionUpdateMany](https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionUpdateMany.en.md)
* [MongoWriteConcern](https://reference.wolfram.com/language/MongoLink/ref/MongoWriteConcern.en.md)

## Tech Notes

* [*MongoLink* Introduction](https://reference.wolfram.com/language/MongoLink/tutorial/MongoLinkSimpleTutorial.en.md)

## Related Guides

* [MongoLink Operations](https://reference.wolfram.com/language/MongoLink/guide/MongoLinkOperations.en.md)