Bulk.find()
Tip
Starting in version 3.2, MongoDB also provides thedb.collection.bulkWrite()
method for performing bulkwrite operations.
Description
New in version 2.6.
Specifies a query condition for an update or a remove operation.
Bulk.find()
accepts the following parameter:
ParameterTypeDescriptionquery
documentSpecifies a query condition using Query Selectors to selectdocuments for an update or a remove operation. To specify all documents,use an empty document {}
.
With update operations, the sum of the query document and the updatedocument must be less than or equal to the maximum BSONdocument size
.
With remove operations, the query document must be less than or equalto the maximum BSON document size
.
Use Bulk.find()
with the following write operations:
Bulk.find.removeOne()
Bulk.find.remove()
Bulk.find.replaceOne()
Bulk.find.updateOne()
Bulk.find.update()
Example
The following example initializes a Bulk()
operations builderfor the items
collection and adds a remove operation and an updateoperation to the list of operations. The remove operation and theupdate operation use the Bulk.find()
method to specify acondition for their respective actions:
- var bulk = db.items.initializeUnorderedBulkOp();
- bulk.find( { status: "D" } ).remove();
- bulk.find( { status: "P" } ).update( { $set: { points: 0 } } )
- bulk.execute();
See also