-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathBulkWriteResult.txt
167 lines (106 loc) · 4.13 KB
/
BulkWriteResult.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
.. _server-bulkwriteresult-method:
=================
BulkWriteResult()
=================
.. default-domain:: mongodb
.. facet::
:name: programming_language
:values: shell
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
.. method:: BulkWriteResult()
A wrapper that contains the results of the :method:`Bulk.execute()`
method.
Compatibility
-------------
This method is available in deployments hosted in the following
environments:
.. include:: /includes/fact-environments-atlas-only.rst
.. include:: /includes/fact-environments-onprem-only.rst
Properties
----------
``BulkWriteResult`` has the following properties:
.. data:: BulkWriteResult.acknowledged
Boolean indicating whether or not the bulk write was acknowledged.
.. data:: BulkWriteResult.deletedCount
Count of deleted documents.
.. data:: BulkWriteResult.insertedCount
Count of inserted documents.
.. data:: BulkWriteResult.insertedIds
.. list-table::
:header-rows: 1
:widths: 10 45 45
* - ``mongosh`` Version
- Description
- Example
* - v1.x
- Array of inserted documents by ``ObjectId``.
- ``[ ObjectId(...), ObjectId(...), ObjectId(...) ]``
* - v2.x
- Map from each inserted document index to its ``ObjectId``.
- ``{ 0: ObjectId(...), 1: ObjectId(...), 2: ObjectId(...) }```
.. data:: BulkWriteResult.matchedCount
Count of matched documents.
.. data:: BulkWriteResult.modifiedCount
Count of modified documents.
.. data:: BulkWriteResult.upsertedCount
Count of upserted documents.
.. data:: BulkWriteResult.upsertedIds
.. list-table::
:header-rows: 1
:widths: 10 45 45
* - ``mongosh`` Version
- Description
- Example
* - v1.x
- Array of upserted documents by ``ObjectId``.
- ``[ ObjectId(...), ObjectId(...), ObjectId(...) ]``
* - v2.x
- Map from each upserted document index to its ``ObjectId``.
- ``{ 0: ObjectId(...), 1: ObjectId(...), 2: ObjectId(...) }```
writeErrors Exception
---------------------
If there is a write error while processing the bulk write,
``mongosh`` raises an exception that contains a ``writeErrors``
property with the following fields:
.. data:: writeErrors
An array of documents that contains information regarding any error,
unrelated to write concerns, encountered during the update
operation. ``writeErrors`` contains an error document for each write
operation that errors.
Each error document contains the following fields:
.. data:: writeErrors.index
Integer that identifies the write operation in the bulk
operations list, which uses a zero-based index. See also
:method:`Bulk.getOperations()`.
.. data:: writeErrors.code
Integer value identifying the error.
.. data:: writeErrors.errmsg
Description of the error.
.. data:: writeErrors.op
A document identifying the operation that failed. For instance,
an update or replace operation error will return a document
specifying the query, the update, the ``multi``, and the
``upsert`` options. An insert opertation returns the document
the operation tried to insert.
writeConcernError Exception
---------------------------
If there is a write concern error while processing the bulk write,
``mongosh`` raises an exception that contains a ``writeConcernError``
property with the following fields:
.. data:: writeConcernError
Document describing errors that relate to the write concern.
.. |cmd| replace:: :method:`BulkWriteResult`
.. include:: /includes/fact-bulk-writeConcernError-mongos
The ``writeConcernError`` documents contains the following fields:
.. data:: writeConcernError.code
Integer value identifying the cause of the write concern error.
.. data:: writeConcernError.errmsg
Description of the cause of the write concern error.
.. data:: writeConcernError.errInfo.writeConcern
.. include:: /includes/fact-errInfo-wc.rst
.. data:: writeConcernError.errInfo.writeConcern.provenance
.. include:: /includes/fact-errInfo-wc-provenance.rst