Bulk.find.remove()
On this page本页内容
Tip
Starting in version 3.2, MongoDB also provides the 从3.2版本开始,MongoDB还提供了db.collection.bulkWrite()
method for performing bulk write operations.db.collection.bulkWrite()
方法来执行批量写入操作。
Description描述
Bulk.find.remove()
-
Starting in从mongosh
0.12.2,Bulk.find.remove()
is an alias forBulk.find.delete()
.mongosh
0.12.2开始,Bulk.find.remove()
是Bulk.find.delete()
的别名。In new code, use在新代码中,请使用Bulk.find.delete()
instead ofBulk.find.remove()
.Bulk.find.delete()
而不是Bulk.find.remove()
。
Example实例
Create the 创建music
collection:music
集合:
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.Bulk()
操作生成器。Searches for the genre搜索pop
.pop
音乐类型。Deletes从集合中删除pop
music from the collection.pop
音乐。
var bulk = db.music.initializeOrderedBulkOp();
bulk.find( { "genre": "pop" } ).remove();
bulk.execute()