On this page本页内容
Starting in version 3.2, MongoDB also provides the 从3.2版开始,MongoDB还提供了用于执行批量写入操作的db.collection.bulkWrite()
method for performing bulk write operations.db.collection.bulkWrite()
方法。
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()
。
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();