Docs Menu

Docs HomeMongoDB Manual

Bulk.find.removeOne()

On this page

  • Description
  • Example

Tip

Starting in version 3.2, MongoDB also provides the db.collection.bulkWrite() method for performing bulk write operations.

Bulk.find.removeOne()

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

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

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

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

Tip

See also:

←  Bulk.find.remove()Bulk.find.replaceOne() →

On this page

Give Feedback
© 2022 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.