Tip
MongoDB は、一括書き込み操作を実行するための Mongo.bulkWrite() メソッドも提供します。
説明
Bulk.find(<query>)アップデート操作または削除操作のクエリ条件を指定します。
Bulk.find()は、次のパラメーターを受け入れます。Parameterタイプ説明queryドキュメント
クエリ述語 を使用してクエリ条件を指定し、アップデートまたは削除操作 の対象となるドキュメントを選択します。すべてのドキュメントを指定するには、空のドキュメント
{}を使用します。更新操作では、クエリ ドキュメントと更新ドキュメントの合計はBSON ドキュメント サイズ 以下である必要があります。
削除操作では、クエリ ドキュメントは最大 BSON ドキュメント サイズ 以下である必要があります。
Use
Bulk.find()with the following write operations:
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
- MongoDB Atlas はクラウドでの MongoDB 配置のための完全管理サービスです
注意
このコマンドは、すべての MongoDB Atlas クラスターでサポートされています。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。
例
The following example initializes a Bulk() operations builder for the items collection and adds a remove operation and an update operation to the list of operations. The remove operation and the update operation use the Bulk.find() method to specify a condition for their respective actions:
var bulk = db.items.initializeUnorderedBulkOp(); bulk.find( { status: "D" } ).delete(); bulk.find( { status: "P" } ).update( { $set: { points: 0 } } ) bulk.execute();