Bulk.find.removeOne()

Tip

Starting in version 3.2, MongoDB also provides thedb.collection.bulkWrite() method for performing bulkwrite operations.

Description

  • Bulk.find.removeOne()

New in version 2.6.

Adds a single document remove operation to a bulk operations list.Use the Bulk.find() method to specify the condition thatdetermines which document to remove. TheBulk.find.removeOne() limits the removal to one document.To remove multiple documents, see Bulk.find.remove().

Example

The following example initializes a Bulk() operations builderfor the items collection and adds twoBulk.find.removeOne() operations to the list of operations.

Each remove operation removes just one document: one document with thestatus equal to "D" and another document with the statusequal to "P".

  1. var bulk = db.items.initializeUnorderedBulkOp();
  2. bulk.find( { status: "D" } ).removeOne();
  3. bulk.find( { status: "P" } ).removeOne();
  4. bulk.execute();

See also