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

Bulk.toString()(mongosh方法)

Bulk.toString()

以字符串形式返回 JSON 文档,其中包含Bulk()对象中的操作和批次数。

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

  • 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 initializes a Bulk() operations builder on the items collection, adds a series of write operations, and calls Bulk.toString() on the bulk builder object.

var bulk = db.items.initializeOrderedBulkOp();
bulk.insert( { item: "abc123", status: "A", defaultQty: 500, points: 5 } );
bulk.insert( { item: "ijk123", status: "A", defaultQty: 100, points: 10 } );
bulk.find( { status: "D" } ).deleteOne();
bulk.toString();
bulk.execute()

The Bulk.toString() returns the following JSON document

{
acknowledged: true,
insertedCount: 2,
insertedIds: [
{ index: 0, _id: ObjectId("627bf4f95e19ff3518448883") },
{ index: 1, _id: ObjectId("627bf4f95e19ff3518448884") }
],
matchedCount: 0,
modifiedCount: 0,
deletedCount: 0,
upsertedCount: 0,
upsertedIds: []
}

提示

Bulk()

给本页内容打分

在此页面上