Bulk.toString()

On this page本页内容

Bulk.toString()

Returns as a string a JSON document that contains the number of operations and batches in the Bulk() object.以字符串形式返回一个JSON文档,该文档包含Bulk()对象中的操作数和批处理数。

Example示例

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.下面将初始化items集合上的Bulk()操作生成器,添加一系列写操作,并对批量生成器对象调用Bulk.toString()

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" } ).removeOne();
bulk.toString();

The Bulk.toString() returns the following JSON documentBulk.toString()返回以下JSON文档

{ "nInsertOps" : 2, "nUpdateOps" : 0, "nRemoveOps" : 1, "nBatches" : 2 }
Tip提示
See also: 参阅:
←  Bulk.tojson()User Management Methods →