对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

Bulk.find.replaceOne()(mongosh方法)

提示

MongoDB 还提供了 Mongo.bulkWrite() 方法用于执行批量写入操作。

Bulk.find.replaceOne(<document>)

Adds a single document replacement operation to a bulk operations list. Use the Bulk.find() method to specify the condition that determines which document to replace. The Bulk.find.replaceOne() method limits the replacement to a single document.

Bulk.find.replaceOne() 接受以下参数:

Parameter
类型
说明

replacement

文档

完全替换现有文档的替换文档。 仅包含字段和值对。

来自Bulk.find()的关联<query>文档与替换文档的总和必须小于或等于最大 BSON 文档大小。

要为此操作指定更新或插入,请参阅Bulk.find.upsert() 。

要指定相关 Bulk.find() 的索引,请参阅 Bulk.find.hint()。

此命令可用于以下环境中托管的部署:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

注意

This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.

The following example initializes a Bulk() operations builder for the items collection, and adds various replaceOne() operations to the list of operations.

var bulk = db.items.initializeUnorderedBulkOp();
bulk.find( { item: "abc123" } ).replaceOne( { item: "abc123", status: "P", points: 100 } );
bulk.execute();
给本页内容打分

在此页面上