Docs HomeMongoDB Manual

BulkWriteResult()

On this page本页内容

BulkWriteResult()

A wrapper that contains the results of the Bulk.execute() method.一个包装器,包含Bulk.execute()方法的结果。

Properties属性

The BulkWriteResult() has the following properties:BulkWriteResult()具有以下属性:

BulkWriteResult.nInserted

The number of documents inserted using the Bulk.insert() method. 使用Bulk.insert()方法插入的文档数。For documents inserted through operations with the Bulk.find.upsert() option, see the nUpserted field instead.有关通过Bulk.find.upsert()选项的操作插入的文档,请参阅“未插入”字段。

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 than nModified.如果更新/替换操作未导致对现有文档的更改,例如$set表达式将值更新为当前值,则nMatched可以大于nModified

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 than nMatched. 如果更新/替换操作没有对现有文档进行更改,例如将字段的值设置为其当前值,则nModified可以小于nMatchedInserted documents do not affect the number of nModified; refer to the nInserted and nUpserted fields instead.插入的文档不会影响nModified的数量;请参阅nInsertednUpserted字段。

BulkWriteResult.nRemoved

The number of documents removed.删除的文档数。

BulkWriteResult.nUpserted

The number of documents inserted through operations with the Bulk.find.upsert() option.通过Bulk.find.upsert()选项的操作插入的文档数。

BulkWriteResult.upserted

An array of documents that contains information for each document inserted through operations with the Bulk.find.upsert() option.一个文档数组,包含通过Bulk.find.upsert()选项的操作插入的每个文档的信息。

Each document contains the following information:每份文件包含以下信息:

BulkWriteResult.upserted.index

An integer that identifies the operation in the bulk operations list, which uses a zero-based index.一个整数,用于标识大容量操作列表中的操作,该列表使用基于零的索引。

BulkWriteResult.upserted._id

The _id value of the inserted document.插入的文档的_id值。

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.writeErrors数组包含每个出错的写入操作的错误文档。

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().另请参阅Bulk.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 document specifying the query, the update, the multi and the upsert options; an insert operation will return the document the operation tried to insert.例如,更新/替换操作错误将返回指定查询、更新、multiupsert选项的文档;插入操作将返回该操作尝试插入的文档。

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.errmsg

A description of the cause of the write concern error.写入关注错误原因的描述。

BulkWriteResult.writeConcernError.errInfo.writeConcern

New in version 4.4. 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). 一个字符串值,指示写入关注的来源(称为写入关注provenance)。The following table shows the possible values for this field and their significance:下表显示了该字段的可能值及其重要性:

Provenance来源Description描述
clientSuppliedThe write concern was specified in the application.写入关注已在应用程序中指定。
customDefaultThe write concern originated from a custom defined default value. 写入关注源自自定义定义的默认值。See setDefaultRWConcern.请参阅setDefaultRWConcern
getLastErrorDefaultsThe write concern originated from the replica set's settings.getLastErrorDefaults field.写入关注源自复制副本集的settings.getLastErrorDefaults字段。
implicitDefaultThe write concern originated from the server in absence of all other write concern specifications.在没有所有其他写入关注规范的情况下,写入关注源自服务器。