A wrapper that contains the result status of
WriteResult() has the following properties:
The number of documents inserted, excluding
WriteResult.nUpsertedfor the number of documents inserted through an upsert.
The number of documents selected for update. If the update operation results in no change to the document, e.g.
$setexpression updates the value to the current value,
nMatchedcan be greater than
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,
nModifiedcan be less than
The number of documents inserted by an upsert.
_idof the document inserted by an
upsert. Returned only if an
upsertresults in an insert.
A document that contains information regarding any error, excluding write concern errors, encountered during the write operation.
A document that contains information regarding any write concern errors encountered during the write operation.
An integer value identifying the cause of the write concern error.
New in version 4.4.
The write concern object used for the corresponding operation. For information on write concern object fields, see Write Concern Specification.
The write concern object may also contain the following field, indicating the source of the write concern:
A string value indicating where the write concern originated (known as write concern
provenance). The following table shows the possible values for this field and their significance:ProvenanceDescription
clientSuppliedThe write concern was specified in the application.
customDefaultThe write concern originated from a custom defined default value. See
getLastErrorDefaultsThe write concern originated from the replica set's
implicitDefaultThe write concern originated from the server in absence of all other write concern specifications.