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()
方法来执行批量写入操作。
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. Bulkfind()
方法指定确定要删除哪个文档的条件。The Bulk.find.removeOne()
limits the removal to one document. Bulk.find.removeOne()
将删除限制为一个文档。To remove multiple documents, see 要删除多个文档,请参阅Bulk.find.remove()
.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.items
集合的Bulk()
操作生成器,并将两个Bulk.find.removeOne()
操作添加到操作列表中。
Each remove operation removes just one document: one document with the 每个删除操作只删除一个文档:一个status
equal to "D"
and another document with the status
equal to "P"
.status
为"D"
的文档和另一个status
为"P"
的文档。