BulkWriteResult()
New in version 2.6.
A wrapper that contains the results of the Bulk.execute()
method.
Properties
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 anexisting document, e.g.
$set
expression updates the valueto the current value,nMatched
can begreater thannModified
.
BulkWriteResult.
nModified
- The number of existing documents updated or replaced. If theupdate/replacement operation results in no change to an existingdocument, such as setting the value of the field to its currentvalue,
nModified
can be less thannMatched
. Inserted documents do not affectthe 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 documentinserted through operations with the
Bulk.find.upsert()
option.
Each document contains the following information:
BulkWriteResult.upserted.
index
An integer that identifies the operation in thebulk operations list, which uses a zero-based index.
- The
_id
value of the inserted document.
BulkWriteResult.
writeErrors
- An array of documents that contains information regarding any error,unrelated to write concerns, encountered during the updateoperation. The
writeErrors
array containsan 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 bulkoperations list, which uses a zero-based index. See also
Bulk.getOperations()
.An integer value identifying the error.
A description of the error.
- A document identifying the operation that failed. For instance,an update/replace operation error will return a documentspecifying the query, the update, the
multi
and theupsert
options; an insert operation will return the documentthe operation tried to insert.
BulkWriteResult.
writeConcernError
Document that describe error related to write concern and containsthe field: