Bulk.toJSON()Devuelve un documento JSON que contiene el número de operaciones y lotes en el objeto
Bulk().
Compatibilidad
Este comando está disponible en implementaciones alojadas en los siguientes entornos:
- MongoDB Atlas: El servicio totalmente gestionado para implementaciones de MongoDB en la nube
Nota
This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.
Ejemplo
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.
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 document
{ acknowledged: true, insertedCount: 2, insertedIds: [ { index: 0, _id: ObjectId("627bf77e5e19ff3518448887") }, { index: 1, _id: ObjectId("627bf77e5e19ff3518448888") } ], matchedCount: 0, modifiedCount: 0, deletedCount: 0, upsertedCount: 0, upsertedIds: [] }
Tip