On this page
Bulk.find.update()
On this page
Tip
Starting in version 3.2, MongoDB also provides the db.collection.bulkWrite() method for performing bulk write operations.
Description
- Bulk.find.- update( <update> )
- 
     New in version 2.6. Adds a multiupdate operation to a bulk operations list. The method updates specific fields in existing documents.Use the Bulk.find()method to specify the condition that determines which documents to update. TheBulk.find.update()method updates all matching documents. To specify a single document update, seeBulk.find.updateOne().Bulk.find.update()accepts the following parameter:Parameter Type Description updatedocument Specifies the fields to update. Only contains update operator expressions. The sum of the associated <query>document from theBulk.find()and the update document must be less than or equal to themaximum BSON document size.- To specify an upsert: true for this operation, use with Bulk.find.upsert(). WithBulk.find.upsert(), if no documents match theBulk.find()query condition, the update operation inserts only a single document.
- To specify arrayFilters to specify which array elements to update, use with Bulk.find.arrayFilters().
- To replace a document wholesale, see Bulk.find.replaceOne().
 
- To specify an upsert: true for this operation, use with 
Example
The following example initializes a Bulk() operations builder for the items collection, and adds various multi update operations to the list of operations.
var bulk = db.items.initializeUnorderedBulkOp();
bulk.find( { status: "D" } ).update( { $set: { status: "I", points: "0" } } );
bulk.find( { item: null } ).update( { $set: { item: "TBD" } } );
bulk.execute();