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.
updateOne
(<update>)¶Adds a single document update operation to a bulk operations list.将单个文档更新操作添加到批量操作列表中。
Use the 使用Bulk.find()
method to specify the condition that determines which document to update. Bulk.find()
方法指定确定要更新哪个文档的条件。The Bulk.find.updateOne()
method limits the update to a single document. Bulk.find.updateOne()
方法将更新限制为单个文档。To update multiple documents, see 要更新多个文档,请参阅Bulk.find.update()
.Bulk.find.update()
。
Bulk.find.updateOne()
accepts the following parameter:接受以下参数:
update |
|
Bulk.find.upsert()
.upsert:true
,请与Bulk.find.upsert()
一起使用。Bulk.find.arrayFilters()
.Bulk.find.arrayFilters()
一起使用。Bulk.find()
, see Bulk.find.hint()
.Bulk.find()
的索引,请参阅Bulkfindhint()
。Bulk.find.replaceOne()
.If the <update>
document contains only update operator expressions, as in:
Then, Bulk.find.updateOne()
updates only the corresponding fields, status
and points
, in the document.
The following example initializes a Bulk()
operations builder for the items
collection, and adds various updateOne
operations to the list of operations.
Starting in version 4.2, update methods can accept an aggregation pipeline. For example, the following uses:
$set
stage which can provide similar behavior to the $set
update operator expression,NOW
, which resolves to the current datetime and can provide similar behavior to a $currentDate
update operator expression. To access aggregation variables, prefix the variable with double dollar signs $$
and enclose in quotes.