BulkWriteResult()

  • 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.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 than nModified.
  • 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 of nModified; refer to thenInserted andnUpserted fields instead.
  • BulkWriteResult.nRemoved
  • The number of documents removed.
  • BulkWriteResult.nUpserted
  • The number of documents inserted through operations with theBulk.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.

  • BulkWriteResult.upserted._id

  • 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 alsoBulk.getOperations().

  • BulkWriteResult.writeErrors.code

  • An integer value identifying the error.

  • BulkWriteResult.writeErrors.errmsg

  • A description of the error.

  • BulkWriteResult.writeErrors.op

  • 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:

    • BulkWriteResult.writeConcernError.code
    • An integer value identifying the cause of the write concern error.

    • BulkWriteResult.writeConcernError.errInfo

    • A document identifying the write concern setting related to theerror.

    • BulkWriteResult.writeConcernError.errmsg

    • A description of the cause of the write concern error.