diff --git a/source/includes/usage-examples/write-code-examples.php b/source/includes/usage-examples/write-code-examples.php index 00e9d894..0471a7e2 100644 --- a/source/includes/usage-examples/write-code-examples.php +++ b/source/includes/usage-examples/write-code-examples.php @@ -1,9 +1,10 @@ db->coll; +$anotherCollection = $client->db->collection; // Inserts one document that stores the specified values // start-insert-one @@ -63,48 +64,29 @@ $result = $collection->deleteMany(['' => '']); // end-delete-multiple -// Runs a bulk operation based on the instructions in each array entry +// Runs a bulk operation based on the operations in the ClientBulkWrite object // start-bulk-write -$result = $collection->bulkWrite( - [ - [ - 'insertOne' => [ - ['' => ''], - ], - ], - [ - 'replaceOne' => [ - ['' => ''], - [ - '' => '', - '' => '', - ], - ], - ], - [ - 'updateOne' => [ - ['' => ''], - ['$set' => ['' => '']], - ], - ], - [ - 'updateMany' => [ - ['' => ''], - ['$set' => ['' => '']], - ], - ], - [ - 'deleteOne' => [ - ['' => ''], - ], - ], - [ - 'deleteMany' => [ - ['' => ''], - ], - ], - ] +$bulkWrite = MongoDB\ClientBulkWrite::createWithCollection($collection); + +$bulkWrite->insertOne(['' => '', '' => '']); + +$bulkWrite->updateOne( + ['' => ''], + ['$set' => ['' => '']], ); + +$bulkWrite = $bulkWrite->withCollection($anotherCollection); + +$bulkWrite->deleteMany( + ['' => ''], +); + +$bulkWrite->replaceOne( + ['' => ''], + ['' => '', '' => ''], +); + +$result = $client->bulkWrite($bulkWrite); // end-bulk-write // Stores a file in a GridFS bucket and writes data to the file diff --git a/source/write.txt b/source/write.txt index 3114e42f..c8eac6e5 100644 --- a/source/write.txt +++ b/source/write.txt @@ -171,7 +171,7 @@ operation: :language: php :dedent: -To learn more about the ``MongoDB\Collection::bulkWrite()`` method, see the +To learn more about the ``MongoDB\Client::bulkWrite()`` method, see the :ref:`Bulk Write ` guide. Store Large Files