Tip
MongoDB は、一括書き込み操作を実行するための db.collection.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 はクラウドでの MongoDB 配置のための完全管理サービスです
注意
このコマンドは、すべての MongoDB Atlas クラスターでサポートされています。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。
例
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();