From 5fc53894b3bee389d12e1dd2ef6f2022fcdafe1b Mon Sep 17 00:00:00 2001 From: rustagir Date: Thu, 29 May 2025 15:55:06 -0400 Subject: [PATCH 1/2] DOCSP-50301: use client bw in write landing pg --- .../usage-examples/write-code-examples.php | 64 +++++++------------ source/write.txt | 2 +- 2 files changed, 24 insertions(+), 42 deletions(-) diff --git a/source/includes/usage-examples/write-code-examples.php b/source/includes/usage-examples/write-code-examples.php index 00e9d894..facd93b4 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 From ce8dde7fedc6585fedc379e1d3f70d87c78f5bbf Mon Sep 17 00:00:00 2001 From: rustagir Date: Thu, 29 May 2025 16:45:09 -0400 Subject: [PATCH 2/2] NR small fixes --- source/includes/usage-examples/write-code-examples.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/includes/usage-examples/write-code-examples.php b/source/includes/usage-examples/write-code-examples.php index facd93b4..0471a7e2 100644 --- a/source/includes/usage-examples/write-code-examples.php +++ b/source/includes/usage-examples/write-code-examples.php @@ -68,7 +68,7 @@ // start-bulk-write $bulkWrite = MongoDB\ClientBulkWrite::createWithCollection($collection); -$bulkWrite->insertOne(['' => '', '' => '']); +$bulkWrite->insertOne(['' => '', '' => '']); $bulkWrite->updateOne( ['' => ''], @@ -83,7 +83,7 @@ $bulkWrite->replaceOne( ['' => ''], - ['' => '', '' => ''], + ['' => '', '' => ''], ); $result = $client->bulkWrite($bulkWrite);