Tip
MongoDB は、一括書き込み操作を実行するための Mongo.bulkWrite() メソッドも提供します。
説明
Bulk.find.replaceOne(<document>)Adds a single document replacement operation to a bulk operations list. Use the
Bulk.find()method to specify the condition that determines which document to replace. TheBulk.find.replaceOne()method limits the replacement to a single document.Bulk.find.replaceOne()は、次のパラメーターを受け入れます。Parameterタイプ説明replacementドキュメント
既存のドキュメントを完全に置き換える置換ドキュメント。 フィールドと値のペアのみが含まれます。
Bulk.find()からの関連する<query>ドキュメントと置換ドキュメントの合計は、 BSON ドキュメントの最大サイズ 以下である必要があります。この操作のアップサートを指定するには、
Bulk.find.upsert()を参照してください。関連する
Bulk.find()に使用するインデックスを指定するには、Bulk.find.hint()を参照してください。
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
注意
This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.
例
The following example initializes a Bulk() operations builder for the items collection, and adds various replaceOne() operations to the list of operations.
var bulk = db.items.initializeUnorderedBulkOp(); bulk.find( { item: "abc123" } ).replaceOne( { item: "abc123", status: "P", points: 100 } ); bulk.execute();