/
WriteResult.txt
99 lines (63 loc) · 2.58 KB
/
WriteResult.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
=============
WriteResult()
=============
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. method:: WriteResult()
A wrapper that contains the result status of the :binary:`~bin.mongo`
shell write methods.
.. see:: :method:`db.collection.insert()`,
:method:`db.collection.update()`,
:method:`db.collection.remove()`, and :method:`db.collection.save()`.
Properties
----------
The :method:`WriteResult` has the following properties:
.. data:: WriteResult.nInserted
The number of documents inserted, excluding ``upserted`` documents.
See :data:`WriteResult.nUpserted` for the number of documents
inserted through an upsert.
.. data:: WriteResult.nMatched
The number of documents selected for update. If the update operation
results in no change to the document, e.g. :update:`$set` expression
updates the value to the current value,
:data:`~WriteResult.nMatched` can be greater than
:data:`~WriteResult.nModified`.
.. data:: WriteResult.nModified
The number of existing documents updated. If the update/replacement
operation results in no change to the document, such as setting the
value of the field to its current value,
:data:`~WriteResult.nModified` can be less than
:data:`~WriteResult.nMatched`.
.. data:: WriteResult.nUpserted
The number of documents inserted by an :ref:`upsert
<upsert-parameter>`.
.. data:: WriteResult._id
The ``_id`` of the document inserted by an ``upsert``. Returned only
if an ``upsert`` results in an insert.
.. data:: WriteResult.nRemoved
The number of documents removed.
.. data:: WriteResult.writeError
A document that contains information regarding any error, excluding
write concern errors, encountered during the write operation.
.. data:: WriteResult.writeError.code
An integer value identifying the error.
.. data:: WriteResult.writeError.errmsg
A description of the error.
.. data:: WriteResult.writeConcernError
A document that contains information regarding any write concern errors encountered
during the write operation.
.. data:: WriteResult.writeConcernError.code
An integer value identifying the write concern error.
.. data:: WriteResult.writeConcernError.errInfo
A document identifying the write concern setting related to the
error.
.. data:: WriteResult.writeConcernError.errmsg
A description of the error.
.. seealso:: :method:`WriteResult.hasWriteError()`,
:method:`WriteResult.hasWriteConcernError()`