Docs Menu

db.collection.initializeUnorderedBulkOp()

Tip

MongoDB は、一括書き込み操作を実行するための db.collection.bulkWrite() メソッドも提供します。

db.collection.initializeUnorderedBulkOp()

重要

mongosh メソッド

このページでは、mongosh メソッドについて記載しています。これは Node.js などの言語固有のドライバーのドキュメントではありません

MongoDB API ドライバーについては、各言語の MongoDB ドライバー ドキュメントを参照してください。

Initializes and returns a new Bulk() operations builder for a collection. The builder constructs an unordered list of write operations that MongoDB executes in bulk.

このコマンドは、次の環境でホストされている配置で使用できます。

  • MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです

注意

このコマンドは、すべての MongoDB Atlas クラスターでサポートされています。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。

With an unordered operations list, MongoDB can execute in parallel the write operations in the list and in any order. If the order of operations matter, use db.collection.initializeOrderedBulkOp() instead.

When executing an unordered list of operations, MongoDB groups the operations. With an unordered bulk operation, the operations in the list may be reordered to increase performance. As such, applications should not depend on the ordering when performing unordered bulk operations.

Bulk(){ のmongosh 操作とドライバーの同等のメソッドでは、グループ内の操作数に制限はありません。一括操作実行用に操作がどのようにグループ化されているかを確認するには、実行Bulk.getOperations() に呼び出します。

以下も参照してください。

If an error occurs during the processing of one of the write operations, MongoDB will continue to process remaining write operations in the list.

The following initializes a Bulk() operations builder and adds a series of insert operations to add multiple documents:

var bulk = db.users.initializeUnorderedBulkOp();
bulk.insert( { user: "abc123", status: "A", points: 0 } );
bulk.insert( { user: "ijk123", status: "A", points: 0 } );
bulk.insert( { user: "mop123", status: "P", points: 0 } );
bulk.execute();

以下も参照してください。