Bulk.find.replaceOne()
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
ドキュメント
A replacement document that completely replaces the existing document. Contains only field and value pairs.
The sum of the associated
<query>
document from theBulk.find()
and the replacement document must be less than or equal to the maximum BSON document size.To specify an upsert for this operation, see
Bulk.find.upsert()
.関連する
Bulk.find()
に使用するインデックスを指定するには、Bulk.find.hint()
を参照してください。
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです
注意
このコマンドは、すべての MongoDB Atlas クラスターでサポートされています。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。
例
次の例では、 items
コレクションで
Bulk()
操作ビルダを初期化し、さまざまな
replaceOne()
操作を操作リストに追加します。
var bulk = db.items.initializeUnorderedBulkOp(); bulk.find( { item: "abc123" } ).replaceOne( { item: "abc123", status: "P", points: 100 } ); bulk.execute();