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(<query>) Specifies a query condition for an update or a remove operation.指定更新或删除操作的查询条件。
Bulk.find() accepts the following parameter:接受以下参数:
query | document |
|
Use 将Bulk.find() with the following write operations:Bulk.find()用于以下写入操作:
The following example initializes a 下面的示例初始化Bulk() operations builder for the items collection and adds a remove operation and an update operation to the list of operations. items集合的Bulk()操作生成器,并将移除操作和更新操作添加到操作列表中。The remove operation and the update operation use the 移除操作和更新操作使用Bulk.find() method to specify a condition for their respective actions:Bulk.find()方法为各自的操作指定条件:
var bulk = db.items.initializeUnorderedBulkOp(); bulk.find( { status: "D" } ).remove(); bulk.find( { status: "P" } ).update( { $set: { points: 0 } } ) bulk.execute();