Bulk.find.remove()
Tip
Starting in version 3.2, MongoDB also provides thedb.collection.bulkWrite()
method for performing bulkwrite operations.
Description
New in version 2.6.
Adds a remove operation to a bulk operations list. Use theBulk.find()
method to specify the condition thatdetermines which documents to remove. TheBulk.find.remove()
method removes all matching documentsin the collection. To limit the remove to a single document, seeBulk.find.removeOne()
.
Example
The following example initializes a Bulk()
operations builderfor the items
collection and adds a remove operation to the list ofoperations. The remove operation removes all documents in thecollection where the status
equals "D"
:
- var bulk = db.items.initializeUnorderedBulkOp();
- bulk.find( { status: "D" } ).remove();
- bulk.execute();
See also