Skip to content

DOCSP-44681: Client bulk write #984

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 9 commits into from
Feb 25, 2025

Conversation

norareidy
Copy link
Collaborator

@norareidy norareidy commented Feb 14, 2025

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-44681
Staging - https://deploy-preview-984--docs-node.netlify.app/fundamentals/crud/write-operations/bulk/

Self-Review Checklist

  • Is this free of any warnings or errors in the RST?
  • Did you run a spell-check?
  • Did you run a grammar-check?
  • Are all the links working?
  • Are the facets and meta keywords accurate?

Copy link

netlify bot commented Feb 14, 2025

Deploy Preview for docs-node ready!

Name Link
🔨 Latest commit ef7890d
🔍 Latest deploy log https://app.netlify.com/sites/docs-node/deploys/67bc9921b55aa20008341548
😎 Deploy Preview https://deploy-preview-984--docs-node.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 site configuration.

Copy link
Collaborator

@rachel-mack rachel-mack left a comment

Choose a reason for hiding this comment

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

A few fixes:

Comment on lines 101 to 106
- Specifies two ``InsertOneModel`` instances in an array. Each ``InsertOneModel``
represents a document to insert into the ``movies`` collection in the
``sample_mflix`` database.
- Calls the ``bulkWrite()`` method on the ``movies`` collection and passes an
array of models as a parameter.
- Prints the number of inserted documents.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be an ordered list - same for the the other lists describing steps in an example.

:language: javascript
:dedent:

.. output::
:language: console
:visible: false

Inserted documents: 4
Inserted documents: 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should be 3.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops

databases, create a ``ClientBulkWriteModel`` for each operation. Then,
call the ``bulkWrite()`` method on your client and pass an array of
models as a parameter. Use the following syntax to create
a ``ClientBulkWriteModel`` that specifies an insert operation:
Copy link
Collaborator

Choose a reason for hiding this comment

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

c+p error?

Suggested change
a ``ClientBulkWriteModel`` that specifies an insert operation:
a ``ClientBulkWriteModel`` that specifies a replace operation:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, thanks for catching!

Comment on lines 134 to 141
.. code-block:: javascript
:copyable: false

{
namespace: "<db>.<collection>",
name: "insertOne",
document: <document to insert>
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Through out this doc you're using a table to describe fields for the collection operations and a code block for the client operations. I think you should use a table for all descriptions. Most of the descriptions will be duplicated from the collection sections, but I think we should assume people will be reading sections individually, and so should provide that same level of detail in each. It also clarifies that the descriptions actually do apply, rather than relying on that assumption.

Also, there's some weird highlighting happening with the blocks because you're using pseudocode.

Comment on lines 583 to 602
The ``BulkWriteResult`` object has the following fields:

- ``insertedCount``: the number of inserted documents
- ``matchedCount``: the number of matched documents
- ``modifiedCount``: the number of updated documents
- ``upsertedCount``: the number of upserted documents
- ``deletedCount``: the number of deleted documents
- ``insertedCount``: The number of inserted documents
- ``matchedCount``: The number of matched documents
- ``modifiedCount``: The number of updated documents
- ``upsertedCount``: The number of upserted documents
- ``deletedCount``: The number of deleted documents

The ``MongoClient.bulkWrite()`` method returns a ``ClientBulkWriteResult`` object,
which has the following fields:

- ``acknowledged``: Indicates whether the bulk write was acknowledged
- ``insertedCount``: The number of inserted documents
- ``matchedCount``: The number of matched documents
- ``modifiedCount``: The number of updated documents
- ``upsertedCount``: The number of upserted documents
- ``deletedCount``: The number of deleted documents
- ``insertResults``: The results of each individual successful insert operation
- ``updateResults``: The results of each individual successful update operation
- ``deleteResults``: The results of each individual successful delete operation
Copy link
Collaborator

Choose a reason for hiding this comment

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

Put these in a table.

Comment on lines +612 to 615
If any bulk write operations called on a collection are unsuccessful,
the {+driver-short+} throws a ``MongoBulkWriteError`` and does not perform any further operations if the
``ordered`` option is set to ``true``. If ``ordered`` is set to ``false``, it will
attempt to continue with subsequent operations.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a link to the Ordered vs Unordered section in the server manual.
https://www.mongodb.com/docs/manual/core/bulk-write-operations/#ordered-vs-unordered-operations

Comment on lines 25 to 26
Bulk operations help reduce the number of calls to the server. Instead of sending
a request for each operation, you can perform multiple operations within one action.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would put this line above the previous paragraph, and include a link to the Bulk Write Operations page in the server guide.

Copy link
Collaborator

@rachel-mack rachel-mack left a comment

Choose a reason for hiding this comment

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

LGTM

@norareidy norareidy requested a review from durran February 24, 2025 16:10
@norareidy norareidy merged commit 483be06 into mongodb:master Feb 25, 2025
5 checks passed
@norareidy norareidy deleted the DOCSP-44681-client-bulk-write branch February 25, 2025 16:16
norareidy added a commit that referenced this pull request Feb 25, 2025
* DOCSP-44681: Client bulk write

* more content

* fixes

* code format

* edit overview

* fix

* RM feedback

* fixes

* DJ feedback

(cherry picked from commit 483be06)
norareidy added a commit that referenced this pull request Feb 25, 2025
* DOCSP-44681: Client bulk write

* more content

* fixes

* code format

* edit overview

* fix

* RM feedback

* fixes

* DJ feedback

(cherry picked from commit 483be06)
norareidy added a commit that referenced this pull request Feb 25, 2025
* DOCSP-44681: Client bulk write

* more content

* fixes

* code format

* edit overview

* fix

* RM feedback

* fixes

* DJ feedback

(cherry picked from commit 483be06)
norareidy added a commit that referenced this pull request Feb 25, 2025
* DOCSP-44681: Client bulk write

* more content

* fixes

* code format

* edit overview

* fix

* RM feedback

* fixes

* DJ feedback

(cherry picked from commit 483be06)
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