Docs Menu

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. The Bulk.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 the Bulk.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();

項目一覧