Skip to content

DOCSP-41448 Write Update Operations Technical Review #48

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

Conversation

shuangela
Copy link
Collaborator

@shuangela shuangela commented Jul 15, 2024

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-41448
Staging - https://preview-mongodbshuangela.gatsbyjs.io/java-rs/DOCSP-41448-write-update-new/tutorials/write-update-documents/

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?

@shuangela shuangela requested review from a team and stIncMale and removed request for a team July 15, 2024 17:09
Comment on lines 97 to 116
To update a single document in a MongoDB collection, call the ``updateOne()``
method and pass your query filter and update operators. Then, pass the ``updateOne()`` result to the static ``Mono.from()`` method from the
``Mono Publisher``. The ``Mono Publisher`` is a ``Publisher`` implementation
from the Project Reactor library. In {+java-rs+}, you must use ``Publisher``
implementations to control how data is transmitted in your application. To learn more
about ``Mono``, see `Mono <https://projectreactor.io/docs/core/release/reference/#mono>`__ in the Project
Reactor documentation.

The following example uses ``Updates.set()`` to update the ``name``
The following example uses the ``updateOne()`` method to update the ``name``
value of a matching document from ``"Bagels N Buns"`` to ``"2 Bagels 2 Buns"``:

.. code-block:: java
:copyable: true

ObservableSubscriber<UpdateResult> updateOneSubscriber = new SubscriberHelpers.OperationSubscriber<>();
restaurants.updateOne(eq("name", "Bagels N Buns"), set("name", "2
Bagels 2 Buns")).subscribe(updateOneSubscriber);
updateOneSubscriber.await();
Publisher<UpdateResult> updatePublisher =
restaurants.updateOne(eq("name", "Bagels N Buns"),
set("name", "2 Bagels 2 Buns"));
Mono.from(updatePublisher).block();
Copy link
Member

Choose a reason for hiding this comment

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

Why are we essentially duplicating here the documentation we also create in #38? And we also approach the explanation differently.

It seems to me that either both of this PRs should be done by the same person, or, even better, the documentation changed in #48 should just link to the documentation introduced in #38 instead of duplicating it using a different style.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi Valentin,

The reason we do this is because the individual pages (like this one, which we call fundamentals pages) and the landing page (#38) have different use cases and different intentions.

The landing page (aka "usage examples") is intended to be a quick reference page with limited explanation where a user can quickly see the syntax of a command and test it using our copyable sample app. It is intended to be very basic and use placeholders instead of real values so that a user can adapt them to their use case.

The individual pages (aka "fundamentals") are meant to explain the concepts of the operation in detail, with code examples focused only on the relevant part of what is being described. The code examples are meant to be correct and idiomatic, but are not intended to be fully runnable without any set up or other contextual code. That is why we have different explanations as well as different examples.

So essentially - landing page = "I'm just looking for syntax of XYZ" whereas the fundamentals page = "I want to know how this works and how I can customize it"

We use this pattern in the PyMongo docs: https://www.mongodb.com/docs/languages/python/pymongo-driver/current/write-operations/ if you want to see an example of this usage live. Let me know if you have any additional questions, but this is a docs strategy/convention for the drivers docs.

@shuangela shuangela requested a review from stIncMale July 16, 2024 21:15
@shuangela shuangela force-pushed the DOCSP-41448-write-update-new branch from c55a628 to a589904 Compare July 22, 2024 21:15
and how to use it, see `Getting Started <https://projectreactor.io/docs/core/release/reference/#getting-started>`__
in the Reactor documentation. To learn more about how we use Project Reactor
library methods and what methods do, see :ref:`Write Data to MongoDB <write-data-reactor-overview>`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
library methods and what methods do, see :ref:`Write Data to MongoDB <write-data-reactor-overview>`.
library methods in this guide and what methods do, see :ref:`Write Data to MongoDB <write-data-reactor-overview>`.

@shuangela shuangela requested a review from stIncMale July 24, 2024 14:28
@shuangela shuangela merged commit c475a92 into mongodb:standardization Jul 24, 2024
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