Docs Home → Develop Applications → MongoDB Manual
BulkWriteResult()![](/docs/v5.2/assets/link.svg)
On this page
BulkWriteResult()
A wrapper that contains the results of the
Bulk.execute()
method.
Properties![](/docs/v5.2/assets/link.svg)
The BulkWriteResult()
has the following properties:
BulkWriteResult.nInserted
The number of documents inserted using the
Bulk.insert()
method. For documents inserted through operations with theBulk.find.upsert()
option, see thenUpserted
field instead.
BulkWriteResult.nMatched
The number of existing documents selected for update or replacement. If the update/replacement operation results in no change to an existing document, e.g.
$set
expression updates the value to the current value,nMatched
can be greater thannModified
.
BulkWriteResult.nModified
The number of existing documents updated or replaced. If the update/replacement operation results in no change to an existing document, such as setting the value of the field to its current value,
nModified
can be less thannMatched
. Inserted documents do not affect the number ofnModified
; refer to thenInserted
andnUpserted
fields instead.
BulkWriteResult.nUpserted
The number of documents inserted through operations with the
Bulk.find.upsert()
option.
BulkWriteResult.upserted
An array of documents that contains information for each document inserted through operations with the
Bulk.find.upsert()
option.Each document contains the following information:
BulkWriteResult.writeErrors
An array of documents that contains information regarding any error, unrelated to write concerns, encountered during the update operation. The
writeErrors
array contains an error document for each write operation that errors.Each error document contains the following fields:
BulkWriteResult.writeErrors.index
An integer that identifies the write operation in the bulk operations list, which uses a zero-based index. See also
Bulk.getOperations()
.
BulkWriteResult.writeConcernError
Document that describe error related to write concern and contains the field:
BulkWriteResult.writeConcernError.code
An integer value identifying the cause of the write concern error.
BulkWriteResult.writeConcernError.errInfo.writeConcern
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:
BulkWriteResult.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. SeesetDefaultRWConcern
.getLastErrorDefaults
The write concern originated from the replica set'ssettings.getLastErrorDefaults
field.implicitDefault
The write concern originated from the server in absence of all other write concern specifications.