Skip to content

DOCSP-46818: Client bulk write #474

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 17 commits into from
Mar 31, 2025

Conversation

norareidy
Copy link
Collaborator

@norareidy norareidy commented Mar 11, 2025

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-46818
Staging - https://deploy-preview-474--docs-golang.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 the facets and meta keywords accurate?
  • Are all the links working?

Copy link

netlify bot commented Mar 11, 2025

Deploy Preview for docs-golang ready!

Name Link
🔨 Latest commit c9e1022
🔍 Latest deploy log https://app.netlify.com/sites/docs-golang/deploys/67ea9cd7c7fc3700084ce20d
😎 Deploy Preview https://deploy-preview-474--docs-golang.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

@rustagir rustagir left a comment

Choose a reason for hiding this comment

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

As I was reviewing I noticed that you have organized this page into functions instead of APIs. Personally, I found it more difficult to move through sections, then find my specific API of interest as opposed to organizing them into two separate sections as we do here . Happy to talk more about how to best organize the page but I think it is confusing to stack the collection/client info in each section

multiple namespaces. In MongoDB, a namespace consists of the database name and the collection
name in the format ``<database>.<collection>``.

.. important::
Copy link
Collaborator

Choose a reason for hiding this comment

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

S: add a title
"Client Bulk Write Compatibility"

@norareidy norareidy requested a review from rustagir March 13, 2025 20:01
Copy link
Collaborator

@rustagir rustagir 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 things but great work fixing up this page!

Comment on lines 24 to 28
method. When calling ``BulkWrite()`` on a ``Collection`` instance, you can
perform multiple write operations on a single collection. When calling
``BulkWrite()`` on a ``Client`` instance, you can perform bulk writes across
multiple namespaces. In MongoDB, a namespace consists of the database name and the collection
name in the format ``<database>.<collection>``.
Copy link
Collaborator

Choose a reason for hiding this comment

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

S: in the bulk write method the namespaces are not given in that format so I recommend removing to avoid confusion

Suggested change
method. When calling ``BulkWrite()`` on a ``Collection`` instance, you can
perform multiple write operations on a single collection. When calling
``BulkWrite()`` on a ``Client`` instance, you can perform bulk writes across
multiple namespaces. In MongoDB, a namespace consists of the database name and the collection
name in the format ``<database>.<collection>``.
method. You can use the ``Collection.BulkWrite()`` method to
perform multiple write operations on a single collection. When calling
the ``Collection.BulkWrite()`` method, you can perform bulk writes across
multiple namespaces. In MongoDB, a namespace consists of a database name and a collection name.

ensure that your application meets the following
requirements:

- Uses {+driver-short+} v2.1 or later
Copy link
Collaborator

Choose a reason for hiding this comment

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

S: remove this first pooint and combine into a sentence. This change will only be on the v2.1+ branch anyways so no need to explicitly include

type, which represents options you can use to modify its behavior. If
you don't specify a ``BulkWriteOptions``, the driver uses the default
values for each option.
Modify Collection-Level Behavior
Copy link
Collaborator

Choose a reason for hiding this comment

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

S suggest moving the options and return value sections to the end of this section after the define write models section (applies to collection and client)

@@ -226,33 +248,36 @@ their behavior with the following methods:
* - ``SetHint()``
- | The index to use to scan for documents.

* - ``SetSort()``
- | The criteria to use when ordering matching documents.
This method is not available for the ``UpdateMnyModel``
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This method is not available for the ``UpdateMnyModel``
This method is only available for the ``UpdateOneModel``


To specify the write operations for your bulk operation on multiple
namespaces, create a ``ClientWriteModel`` for each insert,
replace, update, or delete.
Copy link
Collaborator

Choose a reason for hiding this comment

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

S: add a sentence describing how the first two parameters for each model supply the target namespace

:dedent:
:start-after: begin bulk update model client
:end-before: end bulk update model client

Copy link
Collaborator

Choose a reason for hiding this comment

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

S: add a note that describes updatemany model as an option to update all matching documents

@@ -390,13 +734,21 @@ API Documentation
To learn more about any of the methods or types discussed in this
guide, see the following API Documentation:

- `BulkWrite() <{+api+}/mongo#Collection.BulkWrite>`__
Copy link
Collaborator

Choose a reason for hiding this comment

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

S: consider sorting this into two lists as done on the kotlin sync page

@norareidy norareidy requested a review from rustagir March 14, 2025 19:56
Copy link
Collaborator

@rustagir rustagir left a comment

Choose a reason for hiding this comment

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

great work! just left a comment about a bug but lgtm

Comment on lines 29 to 33
<<<<<<< HEAD
* :ref:`Version 2.1 <golang-version-2.0>`
=======
* :ref:`Version 2.1 <golang-version-2.1>`
>>>>>>> upstream/master
Copy link
Collaborator

Choose a reason for hiding this comment

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

S: I believe there's a merge error still in the PR

@norareidy norareidy requested review from a team and qingyang-hu and removed request for a team March 17, 2025 17:14
To modify the behavior of your bulk write operation, pass a ``BulkWriteOptions``
instance to the ``BulkWrite()`` method.

The ``BulkWriteOptions`` type allows you to configure options by using the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to add SetComment() and SetLet()?

``BulkWriteResult`` type contains the following properties:
includes information about the bulk operation.

The ``BulkWriteResult`` type contains the following properties:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to add the Acknowledged property?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added!

@@ -15,54 +15,243 @@ Bulk Operations
Overview
--------

In this guide, you can learn how to use **bulk operations**.
In this guide, you can learn how to use {+driver-short+} to
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
In this guide, you can learn how to use {+driver-short+} to
In this guide, you can learn how to use {+driver-long+} to

Probably best to use the full name (MongoDB Go Driver) since this is the first occurrence

- | Specifies a document with a list of values to improve operation readability. Values
must be constant or closed expressions that don't reference document fields. For more
information, see the :manual:`let statement
</reference/command/delete/#std-label-delete-let-syntax>` in the {+mdb-server+} manual.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to mention the </reference/command/update/#std-label-update-let-syntax> as well?
Also, do we need to somehow align this section with the SetLet in the "Client-Level Behavior" underneath?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since the description of the let statement is the same on the delete and update page, I don't think we need to link to both. I can remove the link if you think that's confusing. And yes I'll make sure the two definitions align, thanks for catching that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 IMO, a link to a generic reference is not necessary for the Golang-specific doc, neither the delete nor the update. Moreover, listing the delete syntax alone causes a feeling like it's for the delete operation only. However, I'm OK with either keeping the "delete-let-syntax" link or removing it. @jtazin, what are your thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I agree that it could be confusing to link to one and not the other. It sounds like it would be best to either have both or none.
I do like having links for more information, especially since "let" doesn't seem obvious to me.
The Server bulk write documentation includes both. To bad there isn't a way to link directly to the "let" on this page. Perhaps we can copy what we do?
Either way, I don't feel too strongly about this one.
@norareidy and @qingyang-hu let me know if you have additional thoughts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I added links to both the delete and update pages.

@norareidy norareidy requested a review from qingyang-hu March 18, 2025 13:50
@norareidy norareidy requested a review from jtazin March 20, 2025 14:55
@norareidy norareidy merged commit e8c6de2 into mongodb:master Mar 31, 2025
5 checks passed
@norareidy norareidy deleted the DOCSP-46818-client-bulk-write branch March 31, 2025 14:05
norareidy added a commit that referenced this pull request Mar 31, 2025
* DOCSP-46818: Client bulk write

* rest of page

* edits

* RR feedback

* edit

* fix

* edits

* RR feedback 2

* edits

* whats new

* link

* wording

* fix merge error

* tech review

* QH feedback 2

* let links

(cherry picked from commit e8c6de2)
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.

4 participants