Docs Menu

Docs HomeMongoDB Manual

Bulk.find.remove()

On this page

  • Description
  • Example

Tip

Bulk.find.remove()

Starting in mongosh 0.12.2, Bulk.find.remove() is an alias for Bulk.find.delete().

In new code, use Bulk.find.delete() instead of Bulk.find.remove().

Create the music collection:

db.music.insertMany( [
{ artist: "DOA", genre: "punk" },
{ artist: "Rick Astley", genre: "pop" },
{ artist: "Black Flag", genre: "punk" },
{ artist: "Justin Bieber", genre: "pop" }
] )

The following example:

  • Initializes a Bulk() operations builder.

  • Searches for the genre pop.

  • Deletes pop music from the collection.

var bulk = db.music.initializeOrderedBulkOp();
bulk.find( { "genre": "pop" } ).remove();
bulk.execute()
←  Bulk.find.hint()Bulk.find.removeOne() →

On this page