Bulk.find.remove()

On this page本页内容

Tip提示

Starting in version 3.2, MongoDB also provides the db.collection.bulkWrite() method for performing bulk write operations.从3.2版开始,MongoDB还提供了用于执行批量写入操作的db.collection.bulkWrite()方法。

Description描述

Bulk.find.remove()

Adds a remove operation to a bulk operations list. 将移除操作添加到批量操作列表。Use the Bulk.find() method to specify the condition that determines which documents to remove. 使用Bulk.find()方法指定确定要删除哪些文档的条件。The Bulk.find.remove() method removes all matching documents in the collection. Bulk.find.remove()方法删除集合中的所有匹配文档。To limit the remove to a single document, see Bulk.find.removeOne().要将移除限制为单个文档,请参阅Bulk.find.removeOne()

Example示例

The following example initializes a Bulk() operations builder for the items collection and adds a remove operation to the list of operations. 下面的示例初始化items集合的Bulk()操作生成器,并将移除操作添加到操作列表中。The remove operation removes all documents in the collection where the status equals "D":删除操作删除集合中status"D"的所有文档:

var bulk = db.items.initializeUnorderedBulkOp();
bulk.find( { status: "D" } ).remove();
bulk.execute();
←  Bulk.find.hint()Bulk.find.removeOne() →