Bulk.toJSON()Returns a JSON document that contains the number of operations and batches in the返回一个JSON文档,其中包含Bulk()object.Bulk()对象中的操作数和批处理数。
Compatibility兼容性
This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:
- MongoDB Atlas
: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务
Note
This command is supported in all MongoDB Atlas clusters. 所有MongoDB Atlas集群都支持此命令。For information on Atlas support for all commands, see Unsupported Commands.有关Atlas支持所有命令的信息,请参阅不支持的命令。
Example示例
The following initializes a 下面将初始化Bulk() operations builder on the items collection, adds a series of write operations, and calls Bulk.toJSON() on the bulk builder object.items集合上的Bulk()操作构建器,添加一系列写操作,并对bulk构建器对象调用Bulk.toJSON()。
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.toJSON();
The Bulk.toJSON() returns the following JSON documentBulk.toJSON()返回以下JSON文档
{
acknowledged: true,
insertedCount: 2,
insertedIds: [
{ index: 0, _id: ObjectId("627bf77e5e19ff3518448887") },
{ index: 1, _id: ObjectId("627bf77e5e19ff3518448888") }
],
matchedCount: 0,
modifiedCount: 0,
deletedCount: 0,
upsertedCount: 0,
upsertedIds: []
}