Skip to content

DOCSP-49150: bulkWrite docs + api #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 21, 2025

Conversation

Copy link

netlify bot commented May 20, 2025

Deploy Preview for docs-php-library ready!

Name Link
🔨 Latest commit 7166329
🔍 Latest deploy log https://app.netlify.com/projects/docs-php-library/deploys/682e2e177303920008308cc9
😎 Deploy Preview https://deploy-preview-250--docs-php-library.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@rustagir rustagir requested a review from GromNaN May 20, 2025 13:28
Comment on lines +33 to +38
- :ref:`Collection <php-coll-bulk-write>`: You can use the
``MongoDB\Collection::bulkWrite()`` method to perform bulk write
operations on a single collection. This method makes a database call
for each type of write operation. For example, the method can perform
multiple update operations in one call, but makes two separate calls to
the database for an insert operation and a replace operation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today I learned that collection bulk write is a driver implementation only to batch individual commands. Confirmed by the spec.

@rustagir rustagir requested a review from GromNaN May 20, 2025 15:37
@rustagir rustagir mentioned this pull request May 21, 2025
7 tasks
@rustagir rustagir requested a review from GromNaN May 21, 2025 14:00
@rustagir rustagir requested a review from GromNaN May 21, 2025 14:44
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a massive piece of work, well done.

Copy link
Contributor

@norareidy norareidy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing work!! I mostly suggested small updates but I'll take another look because of the question I left

Comment on lines 17 to 18
<mongodb-driver-exception-bulkwritecommandexception>` is thrown, users should call
:php:`getWriteErrors() <mongodb-driver-bulkwritecommandexception.getwriteerrors>` and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S: second person / present tense; although it seems like a lot of these use "users" so that change is not necessary

Suggested change
<mongodb-driver-exception-bulkwritecommandexception>` is thrown, users should call
:php:`getWriteErrors() <mongodb-driver-bulkwritecommandexception.getwriteerrors>` and
<mongodb-driver-exception-bulkwritecommandexception>` is thrown, you can call
:php:`getWriteErrors() <mongodb-driver-bulkwritecommandexception.getwriteerrors>` and

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can change in all extracts, nbd


.. phpclass:: MongoDB\BulkWriteCommandResult

This class contains information about an executed client bulk write operation. It
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S: to avoid "execute":

Suggested change
This class contains information about an executed client bulk write operation. It
This class contains information about a completed client bulk write operation. It

Comment on lines 60 to 61
- | Returns a boolean indicating whether the bulk operation was
acknowledged by the server.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s: active voice

Suggested change
- | Returns a boolean indicating whether the bulk operation was
acknowledged by the server.
- | Returns a boolean indicating whether the server acknowledged the bulk operation.


Represents the assembled bulk write command or builder.
:phpmethod:`MongoDB\Client::bulkWrite()` supports
``deleteMany``, ``deleteOne()``, ``insertOne()``,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S:

Suggested change
``deleteMany``, ``deleteOne()``, ``insertOne()``,
``deleteMany()``, ``deleteOne()``, ``insertOne()``,

Comment on lines 51 to 52
- If ``true``, allows the write operation to circumvent document level
validation. Defaults to ``false``.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S: to match the format of the other entries

Suggested change
- If ``true``, allows the write operation to circumvent document level
validation. Defaults to ``false``.
- If ``true``: Allows the write operation to circumvent document level
validation.
The default is ``false``.

To delete multiple documents, call the ``deleteMany()`` method. The specified
operation deletes *all documents* that match the query filter.

The following example specifies deletion of all matching documents in the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S:

Suggested change
The following example specifies deletion of all matching documents in the
The following example specifies a deletion of all matching documents in the

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to the deletion

instance of the ``ClientBulkWrite`` class, then call the ``deleteOne()``
method.

The following example specifies deletion of a document in the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S:

Suggested change
The following example specifies deletion of a document in the
The following example specifies a deletion of a document in the

operation deletes *all documents* that match the query filter.

The following example specifies deletion of all matching documents in the
``sample_restaurants.restaurants`` collection:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S: might be worth explaining which documents this code is actually matching, since it's not immediately clear from the regex what's going on - like "all documents in the collection that have a name value containing at least two 'p' characters"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add descriptions to all of these examples!

Comment on lines 269 to 271
performing the remaining writes and throws an exception.
| If set to ``false``: when a single write fails, the operation continues to
attempt the remaining write operations, if any, then throws an exception.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S: to avoid "throws"

Suggested change
performing the remaining writes and throws an exception.
| If set to ``false``: when a single write fails, the operation continues to
attempt the remaining write operations, if any, then throws an exception.
performing the remaining writes and generates an exception.
| If set to ``false``: when a single write fails, the operation continues to
attempt the remaining write operations, if any, then generates an exception.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"throw" is a PHP keyword. It has a specific meaning in this context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to returns

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw this - will revert

Comment on lines 287 to 288
If the library runs the insert operation first, one document is deleted.
If it runs the delete operation first, no documents are deleted.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: which insert and delete operation are you referring to here? do you just mean any insert and delete where the delete operation targets that inserted document?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a copypaste issue - I will remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the note in this section to describe the same situation

@rustagir rustagir requested a review from norareidy May 21, 2025 19:46
Copy link
Contributor

@norareidy norareidy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rustagir rustagir merged commit c614e24 into mongodb:master May 21, 2025
6 of 8 checks passed
rustagir added a commit that referenced this pull request May 23, 2025
* DOCSP-44581: v2 release (#234)

* DOCSP-44581: v2 release

* small fix

* Add missing meta descriptions (#235)

* Add missing meta descriptions

* Apply suggestions from code review

---------

Co-authored-by: Rachel Mackintosh <[email protected]>

* DOCSP-48761: docker note (#237)

* DOCSP-48100: Consolidate minor versions (#240)

* DOCSP-48100: Consolidate minor versions

* edits

* remove old redirects

* AB feedback

* edit

* DOCSP-48718-update-credentials (#247)

* update username and password

* misspelling

* redirects

* pre-standardization redirects

* upgrade composer package vs

* DOCSP-49150: bulkWrite docs + api (#250)

* DOCSP-49150: bulkWrite docs + api

* first pass fixes

* JT PR fixes 1

* upgrade composer package vs

* JT PR fixes 2

* small fix

* JT PR fixes 3

* remove reference to writeconcern option

* add return values sections

* object -> instance

* NR PR fixes 1

* returns -> throws

* DOCSP-50022: remove eol server version mentions (#253)

* DOCSP-50022: remove eol server version mentions

* consolidate compat table rows

* DOCSP-50155 - EOL MongoDB 4.0 (#252)

* eol v4.0

* update compat

* DOCSP-50294: v2.1 release (#255)

---------

Co-authored-by: Nick Larew <[email protected]>
Co-authored-by: Rachel Mackintosh <[email protected]>
Co-authored-by: Nora Reidy <[email protected]>
Co-authored-by: shuangela <[email protected]>
Co-authored-by: Mike Woofter <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants