MongoDB.DeleteMany
------------------

Deletes many records.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [MongoDB](component_MongoDB.md) | [12.3](newinversion123.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "MongoDB.DeleteMany"; MongoDBRef; selectorJSON { ; OptionsJSON } ) 

**MBS**( **"MongoDB.DeleteMany";** /\* Deletes many records. \*/  
**$MongoDBRef**; /\* The reference number for the mongo connection.e.g. $MongoDB \*/   
**$selectorJSON**; /\* A JSON containing the query to match documents for deleting. \*/   
**$OptionsJSON**) /\* Optional; Options as JSON. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| MongoDBRef | The reference number for the mongo connection. | $MongoDB |  |
| selectorJSON | A JSON containing the query to match documents for deleting. |  |  |
| OptionsJSON | Options as JSON. |  | Optional |

### Result

Returns JSON or error.

### Description

Deletes many records.  
This function removes all documents in the given collection that match selector.  
  
To delete at most one matching document, use [MongoDB.DeleteOne](MongoDBDeleteOne.md).  
### Examples

Delete several matching documents:

 Set Variable \[ $r ; Value: MBS ( "MongoDB.DeleteMany"; $Mongo ; "{\\"Hello\\": \\"World\\"}") \]  
### See also

- [MongoDB.DeleteOne](MongoDBDeleteOne.md)
- [MongoDB.InsertMany](MongoDBInsertMany.md)
- [MongoDB.UpdateMany](MongoDBUpdateMany.md)

### Example Databases

- [MongoDB/MongoDB Blog](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/MongoDB/MongoDB%20Blog.shtml#21ScriptAnchor_)

### FileMaker Magazin

- [Ausgabe 1/2025, Seite 26](https://filemaker-magazin.de/neuigkeit/4282-Appetithappen-FMM_202501)

This function checks for a license.

Created 27th May 2022 , last changed 20th June 2022

  
[MongoDB.DatabasesNames](MongoDBDatabasesNames.md) - [MongoDB.DeleteOne](MongoDBDeleteOne.md)

[HTML Version](MongoDBDeleteMany.shtml)