On this page



Deletes one or more documents from a MongoDB collection.


In order to use MongoDB service actions, you must have rules set up for each namespace included in the operation.

You can only use the delete action in the first stage of a pipeline. The delete action stage has the following syntax:

     "database": <dbname>,
     "collection": <collection name>,
     "pipeline":[<aggregation stage1>, ...]

The aggregate action takes the following arguments:

Argument Type Description
database string Name of the database.
collection string Name of the collection.
query document Query filter to apply for the delete operation. Specify the filter as a JSON document. Filter expression can include MongoDB query expressions as well as variables (%%vars) defined in the stage.
singleDoc boolean Optional. If set to true, limits the delete to a single document. If set to false,delete all documents that match the query. The default value is false.


Consider the following pipeline that performs a delete operation on the specified collection:

   "service": "mongodb-atlas",
   "action": "delete",
   "args":{"database": "my_db", "collection": "reports", "singleDoc": false, "query": {"cust_id": "A"}}

Stage1: The MongoDB delete stage deletes all documents that match the query filter {"cust_id": "A"} from the my_db.reports collection.

See also

Pipelines examples.

←   aggregate find  →