ANNOUNCEMENT: Voyage AI joins MongoDB to power more accurate and trustworthy AI applications on Atlas.
Learn more
Docs Menu

BulkWriteResult()

BulkWriteResult()

A wrapper that contains the results of the Bulk.execute() method.

이 메서드는 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.

  • MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스

BulkWriteResult has the following properties:

BulkWriteResult.acknowledged

Boolean indicating whether or not the bulk write was acknowledged.

BulkWriteResult.deletedCount

Count of deleted documents.

BulkWriteResult.insertedCount

Count of inserted documents.

BulkWriteResult.insertedIds
mongosh 버전
설명
예시

v1.x

Array of inserted documents by ObjectId.

[ ObjectId(...), ObjectId(...), ObjectId(...) ]

v2.x

Map from each inserted document index to its ObjectId.

{ 0: ObjectId(...), 1: ObjectId(...), 2: ObjectId(...) }`

BulkWriteResult.matchedCount

Count of matched documents.

BulkWriteResult.modifiedCount

Count of modified documents.

BulkWriteResult.upsertedCount

Count of upserted documents.

BulkWriteResult.upsertedIds
mongosh 버전
설명
예시

v1.x

Array of upserted documents by ObjectId.

[ ObjectId(...), ObjectId(...), ObjectId(...) ]

v2.x

Map from each upserted document index to its ObjectId.

{ 0: ObjectId(...), 1: ObjectId(...), 2: ObjectId(...) }`

If there is a write error while processing the bulk write, mongosh raises an exception that contains a writeErrors property with the following fields:

writeErrors

An array of documents that contains information regarding any error, unrelated to write concerns, encountered during the update operation. writeErrors contains an error document for each write operation that errors.

각 오류 문서에는 다음과 같은 필드가 포함되어 있습니다.

writeErrors.index

Integer that identifies the write operation in the bulk operations list, which uses a zero-based index. See also Bulk.getOperations().

writeErrors.code

Integer value identifying the error.

writeErrors.errmsg

Description of the error.

writeErrors.op

A document identifying the operation that failed. For instance, an update or replace operation error will return a document specifying the query, the update, the multi, and the upsert options. An insert opertation returns the document the operation tried to insert.

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:

writeConcernError

Document 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 from mongos, write concern errors are always reported, even when one or more write errors occur. In previous releases, the occurrence of write errors could cause the BulkWriteResult() to not report write concern errors.

각 오류 문서에는 다음과 같은 필드가 포함되어 있습니다.

writeConcernError.code

Integer value identifying the cause of the write concern error.

writeConcernError.errmsg

Description of the cause of the write concern error.

writeConcernError.errInfo.writeConcern

해당 작업에 사용되는 쓰기 관련 객체입니다. 쓰기 문제 객체 필드에 대한 자세한 내용은 쓰기 문제 사양을 참조하세요.

쓰기 고려 객체에는 쓰기 문제의 원본을 나타내는 다음 필드도 포함될 수 있습니다.

writeConcernError.errInfo.writeConcern.provenance

쓰기 문제가 발생한 위치를 나타내는 문자열 값입니다(쓰기 문제 provenance 라고도 함). 다음 표에는 이 필드에 사용할 수 있는 값과 그 의미가 나와 있습니다.

출처
설명

clientSupplied

쓰기 우려 사항은 애플리케이션에서 지정되었습니다.

customDefault

쓰기 고려는 사용자 정의된 기본값에서 비롯된 것입니다. setDefaultRWConcern을 참조하십시오.

getLastErrorDefaults

쓰기 고려는 복제본 세트의 settings.getLastErrorDefaults 필드에서 발생했습니다.

implicitDefault

쓰기 고려는 다른 모든 쓰기 고려 사양이 없는 상태에서 서버에서 발생했습니다.