Skip to main content
MongoDB

MongoDB - Delete multiple documents

MongoDB - Delete multiple documents

Deletes every document in a MongoDB collection that matches the given filter.


Options

Collection

Reference to the MongoDB: Select collection action the deletion will run on.

Filter (query)

Filter identifying the documents to delete, for example { "status": "inativo" }.

Transaction (optional)

Reference to a MongoDB: Start transaction action when the operation must run inside a transaction. Optional field, available under the advanced options.

Returns

Javascript code

js
actions["action-id"].deletedCount // number of deleted documents (Any)

Field selection

  • deletedCount — number of documents that were deleted (Any)

Rules and Conditions

  • The Collection and Filter fields are required.
  • Every document matching the filter is deleted.
  • If no document matches the filter, nothing is deleted.
  • Use with care: an empty filter ({}) deletes every document in the collection.