-
Notifications
You must be signed in to change notification settings - Fork 17
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
DOCSP-41448 Write Update Operations Technical Review #48
Conversation
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
c55a628
to
a589904
Compare
source/includes/reactor-note.rst
Outdated
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>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>`. |
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