-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathBulk.toString.txt
64 lines (47 loc) · 1.51 KB
/
Bulk.toString.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
===============
Bulk.toString()
===============
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
.. method:: Bulk.toString()
Returns as a string a JSON document that contains the number of
operations and batches in the :method:`Bulk()` object.
Compatibility
-------------
This command is available in deployments hosted in the following
environments:
.. include:: /includes/fact-environments-atlas-only.rst
.. include:: /includes/fact-environments-atlas-support-all.rst
Example
-------
The following initializes a :method:`Bulk()` operations builder on the
``items`` collection, adds a series of write operations, and calls
:method:`Bulk.toString()` on the ``bulk`` builder object.
.. code-block:: javascript
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 :method:`Bulk.toString()` returns the following JSON document
.. code-block:: javascript
{
acknowledged: true,
insertedCount: 2,
insertedIds: [
{ index: 0, _id: ObjectId("627bf4f95e19ff3518448883") },
{ index: 1, _id: ObjectId("627bf4f95e19ff3518448884") }
],
matchedCount: 0,
modifiedCount: 0,
deletedCount: 0,
upsertedCount: 0,
upsertedIds: []
}
.. seealso::
:method:`Bulk()`