BulkWriteResult()
BulkWriteResult()
A wrapper that contains the results of the
Bulk.execute()
method.
Compatibility
This method is available in deployments hosted in the following environments:
MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
MongoDB Enterprise: The subscription-based, self-managed version of MongoDB
MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB
Properties
BulkWriteResult
has the following properties:
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:
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:
writeErrors.index
Integer that identifies the write operation in the bulk operations list, which uses a zero-based index. See also
Bulk.getOperations()
.
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:
writeConcernError
Document describing errors that relate to the write concern.
Changed in version 7.1: When
BulkWriteResult()
is received frommongos
, write concern errors are always reported, even when one or more write errors occur.In previous releases, the occurrence of write errors could cause the
BulkWriteResult()
to not report write concern errors.The
writeConcernError
documents contains the following fields:writeConcernError.errInfo.writeConcern
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:
writeConcernError.errInfo.writeConcern.provenance
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:ProvenanceDescriptionclientSupplied
The write concern was specified in the application.
customDefault
The write concern originated from a custom defined default value. See
setDefaultRWConcern
.getLastErrorDefaults
The write concern originated from the replica set's
settings.getLastErrorDefaults
field.implicitDefault
The write concern originated from the server in absence of all other write concern specifications.