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:
writeErrorsAn array of documents that contains information regarding any error, unrelated to write concerns, encountered during the update operation.
writeErrorscontains an error document for each write operation that errors.Each error document contains the following fields:
writeErrors.indexInteger 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:
writeConcernErrorDocument describing errors that relate to the write concern.
Changed in version 7.0.6: (also available in 6.0.14 and 5.0.30): 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 theBulkWriteResult()to not report write concern errors.Each error document contains the following fields:
writeConcernError.errInfo.writeConcernThe 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.provenanceA 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:ProvenanceDescriptionclientSuppliedThe write concern was specified in the application.
customDefaultThe write concern originated from a custom defined default value. See
setDefaultRWConcern.getLastErrorDefaultsThe write concern originated from the replica set's
settings.getLastErrorDefaultsfield.implicitDefaultThe write concern originated from the server in absence of all other write concern specifications.