@@ -20,110 +20,130 @@ BulkWriteResult()
20
20
Properties
21
21
----------
22
22
23
- The :method:` BulkWriteResult` has the following properties:
23
+ `` BulkWriteResult` ` has the following properties:
24
24
25
- .. data:: BulkWriteResult.nInserted
25
+ .. data:: BulkWriteResult.acknowledged
26
26
27
- The number of documents inserted using the :method:`Bulk.insert()`
28
- method. For documents inserted through operations with the
29
- :method:`Bulk.find.upsert()` option, see the
30
- :data:`~BulkWriteResult.nUpserted` field instead.
27
+ Boolean indicating whether or not the bulk write was acknowledged.
31
28
32
- .. data:: BulkWriteResult.nMatched
29
+ .. data:: BulkWriteResult.deletedCount
33
30
34
- The number of existing documents selected for update or replacement.
35
- If the update/replacement operation results in no change to an
36
- existing document, e.g. :update:`$set` expression updates the value
37
- to the current value, :data:`~BulkWriteResult.nMatched` can be
38
- greater than :data:`~BulkWriteResult.nModified`.
31
+ Count of deleted documents.
39
32
40
- .. data:: BulkWriteResult.nModified
33
+ .. data:: BulkWriteResult.insertedCount
41
34
42
- The number of existing documents updated or replaced. If the
43
- update/replacement operation results in no change to an existing
44
- document, such as setting the value of the field to its current
45
- value, :data:`~BulkWriteResult.nModified` can be less than
46
- :data:`~BulkWriteResult.nMatched`. Inserted documents do not affect
47
- the number of :data:`~BulkWriteResult.nModified`; refer to the
48
- :data:`~BulkWriteResult.nInserted` and
49
- :data:`~BulkWriteResult.nUpserted` fields instead.
35
+ Count of inserted documents.
50
36
51
- .. data:: BulkWriteResult.nRemoved
37
+ .. data:: BulkWriteResult.insertedIds
52
38
53
- The number of documents removed.
39
+ .. list-table::
40
+ :header-rows: 1
41
+ :widths: 10 45 45
54
42
55
- .. data:: BulkWriteResult.nUpserted
43
+ * - ``mongosh`` Version
44
+ - Description
45
+ - Example
56
46
57
- The number of documents inserted through operations with the
58
- :method:`Bulk.find.upsert()` option.
47
+ * - v1.x
48
+ - Array of inserted documents by ``ObjectId``.
49
+ - ``[ ObjectId(...), ObjectId(...), ObjectId(...) ]``
59
50
60
- .. data:: BulkWriteResult.upserted
51
+ * - v2.x
52
+ - Map from each inserted document index to its ``ObjectId``.
53
+ - ``{ 0: ObjectId(...), 1: ObjectId(...), 2: ObjectId(...) }```
61
54
62
- An array of documents that contains information for each document
63
- inserted through operations with the :method:`Bulk.find.upsert()`
64
- option.
55
+ .. data:: BulkWriteResult.matchedCount
65
56
66
- Each document contains the following information:
57
+ Count of matched documents.
67
58
68
- .. data:: BulkWriteResult.upserted.index
59
+ .. data:: BulkWriteResult.modifiedCount
69
60
70
- An integer that identifies the operation in the
71
- bulk operations list, which uses a zero-based index.
61
+ Count of modified documents.
72
62
73
- .. data:: BulkWriteResult.upserted._id
63
+ .. data:: BulkWriteResult.upsertedCount
74
64
75
- The ``_id`` value of the inserted document .
65
+ Count of upserted documents .
76
66
77
- .. data:: BulkWriteResult.writeErrors
67
+ .. data:: BulkWriteResult.upsertedIds
68
+
69
+ .. list-table::
70
+ :header-rows: 1
71
+ :widths: 10 45 45
72
+
73
+ * - ``mongosh`` Version
74
+ - Description
75
+ - Example
76
+
77
+ * - v1.x
78
+ - Array of upserted documents by ``ObjectId``.
79
+ - ``[ ObjectId(...), ObjectId(...), ObjectId(...) ]``
80
+
81
+ * - v2.x
82
+ - Map from each upserted document index to its ``ObjectId``.
83
+ - ``{ 0: ObjectId(...), 1: ObjectId(...), 2: ObjectId(...) }```
84
+
85
+ writeErrors Exception
86
+ ---------------------
87
+
88
+ If there is a write error while processing the bulk write,
89
+ ``mongosh`` raises an exception that contains a ``writeErrors``
90
+ property with the following fields:
91
+
92
+ .. data:: writeErrors
78
93
79
94
An array of documents that contains information regarding any error,
80
95
unrelated to write concerns, encountered during the update
81
- operation. The :data:`~BulkWriteResult. writeErrors` array contains
82
- an error document for each write operation that errors.
96
+ operation. `` writeErrors`` contains an error document for each write
97
+ operation that errors.
83
98
84
99
Each error document contains the following fields:
85
100
86
- .. data:: BulkWriteResult. writeErrors.index
101
+ .. data:: writeErrors.index
87
102
88
- An integer that identifies the write operation in the bulk
103
+ Integer that identifies the write operation in the bulk
89
104
operations list, which uses a zero-based index. See also
90
105
:method:`Bulk.getOperations()`.
91
106
92
- .. data:: BulkWriteResult. writeErrors.code
107
+ .. data:: writeErrors.code
93
108
94
- An integer value identifying the error.
109
+ Integer value identifying the error.
95
110
96
- .. data:: BulkWriteResult. writeErrors.errmsg
111
+ .. data:: writeErrors.errmsg
97
112
98
- A description of the error.
113
+ Description of the error.
99
114
100
- .. data:: BulkWriteResult. writeErrors.op
115
+ .. data:: writeErrors.op
101
116
102
117
A document identifying the operation that failed. For instance,
103
- an update/ replace operation error will return a document
104
- specifying the query, the update, the ``multi`` and the
105
- ``upsert`` options; an insert operation will return the document
118
+ an update or replace operation error will return a document
119
+ specifying the query, the update, the ``multi``, and the
120
+ ``upsert`` options. An insert opertation returns the document
106
121
the operation tried to insert.
107
122
108
- .. data:: BulkWriteResult.writeConcernError
123
+ writeConcernError Exception
124
+ ---------------------------
125
+
126
+ If there is a write concern error while processing the bulk write,
127
+ ``mongosh`` raises an exception that contains a ``writeConcernError``
128
+ property with the following fields:
109
129
110
- Document that describe error related to write concern and contains
111
- the field:
130
+ .. data:: writeConcernError
112
131
113
- .. data:: BulkWriteResult.writeConcernError.code
132
+ Document that describes the error related to write concern and
133
+ contains the fields:
114
134
115
- An integer value identifying the cause of the write concern error.
135
+ .. data:: writeConcernError.code
116
136
117
- .. data:: BulkWriteResult.writeConcernError.errmsg
137
+ Integer value identifying the cause of the write concern error.
118
138
119
- A description of the cause of the write concern error.
139
+ .. data:: writeConcernError.errmsg
120
140
121
- .. data:: BulkWriteResult.writeConcernError.errInfo.writeConcern
141
+ Description of the cause of the write concern error.
122
142
123
- .. versionadded :: 4.4
143
+ .. data :: writeConcernError.errInfo.writeConcern
124
144
125
145
.. include:: /includes/fact-errInfo-wc.rst
126
146
127
- .. data:: BulkWriteResult. writeConcernError.errInfo.writeConcern.provenance
147
+ .. data:: writeConcernError.errInfo.writeConcern.provenance
128
148
129
149
.. include:: /includes/fact-errInfo-wc-provenance.rst
0 commit comments