定義
WriteResult()A wrapper that contains the result status of
mongoshwrite methods.注意
db.collection.insert()とdb.collection.update()は非推奨です。The results returned by the replacement methods have a different format. For output similar to
WriteResult(), consider usingdb.collection.bulkWrite().
互換性
このメソッドは、次の環境でホストされている配置で使用できます。
- MongoDB Atlas はクラウドでの MongoDB 配置のための完全管理サービスです
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
プロパティ
The WriteResult() has the following properties:
WriteResult.nInsertedThe number of documents inserted, excluding
upserteddocuments. SeeWriteResult.nUpsertedfor the number of documents inserted through an upsert.
WriteResult.nMatchedThe number of documents selected for update. If the update operation results in no change to the document, e.g.
$setexpression updates the value to the current value,nMatchedcan be greater thannModified.
WriteResult.nModifiedThe number of existing documents updated. If the update/replacement operation results in no change to the document, such as setting the value of the field to its current value,
nModifiedcan be less thannMatched.
WriteResult.writeConcernError書込み保証 (write concern) に関連するエラーを説明するドキュメント。
バージョン 7.0.6 での変更
( および でも利用可能6.0.145.0.30 ):
WriteResult()がmongosから受信されると、1 つ以上の書込みエラーが発生しても、書込み保証 (write concern)エラーが常に報告されます。以前のリリースでは、書込みエラーが発生すると、 は書込み保証WriteResult()(write concern)エラーを報告しないことがありました。各エラー ドキュメントには以下のフィールドが含まれます。
WriteResult.writeConcernError.errInfo.writeConcern対応する操作に使用される書込み保証 (write concern) オブジェクトです。書込み保証 (write concern) オブジェクト フィールドの詳細については、「書込み保証 (write concern) の仕様」を参照してください。
書込み保証 (write concern) オブジェクトには、書込み保証 (write concern) のソースを示す以下のフィールドも含むことができます。
WriteResult.writeConcernError.errInfo.writeConcern.provenance書込み保証 (write concern) が発生した場所を示す文字列値です(書込み保証 (write concern)
provenanceと呼ばれます)。次の表は、このフィールドに指定できる値とその意味を示しています。出所説明clientSupplied書き込み保証(write concern)がアプリケーションで指定されました。
customDefault書込み保証 (write concern) は、カスタム定義されたデフォルト値に基づきます。
setDefaultRWConcernを参照してください。getLastErrorDefaults書込み保証 (write concern) は、レプリカセットの
settings.getLastErrorDefaultsのフィールドに基づきます。implicitDefault他の書き込み保証(write concern)が一切指定されていない状態で、サーバーから発生した書き込み保証。