-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DOCSP-35947: write operations modify documents #2808
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-35947: write operations modify documents #2808
Conversation
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.
Looks good, requesting changes since I left a couple questions!
When the ``save()`` method succeeds, the model instance on which you called the | ||
method. |
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.
I: I think this sentence is incomplete. You could add something like this:
When the ``save()`` method succeeds, the model instance on which you called the | |
method. | |
When the ``save()`` method succeeds, the model instance on which you called the | |
method contains the updated values. |
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.
Whoops, good catch! Will update.
it by calling the ``update()`` method or other helper methods. | ||
|
||
The following example shows how to update a document by modifying an instance | ||
of the model and calling its ``save()`` method: |
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.
S: not necessary, but I like the detailed description of the code example in lines 86-94. Could be helpful to introduce this code example with more specific info
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.
Is there specific info that you think might be helpful to add? I think the insert example adds type information which sets up the rest of the examples on the page, but could be repetitive and draw away from the focus of the rest of the examples.
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.
I was thinking of specifying which fields / values you're updating (venue
, ticketsSold
), but agreed that this could be repetitive and I think it's fine as is!
Eloquent lets you specify criteria to retrieve documents, perform updates on | ||
the returned object collections, and save them. |
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.
Q: this description is a little confusing - what is returning the "object collections"? Are you using "documents" and "object collections" interchangeably in this sentence?
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.
I'll replace the sentence with what I think might be less confusing.
I think I meant collection object. I can clarify further by using either the class name or adjective "Eloquent".
The following example shows how to update a document by using fluent syntax to | ||
retrieve the first match and apply updates to the matching document: |
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.
S: I think you can condense this description a little; also, the other mentions of "fluent syntax" use "the", so I'd do the same here
The following example shows how to update a document by using fluent syntax to | |
retrieve the first match and apply updates to the matching document: | |
The following example shows how to use the fluent syntax to | |
retrieve and update the first matching document: |
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.
Good suggestion, thanks!
|
||
To perform an update on one or more documents, call the ``update()`` | ||
method on a collection of model objects. You can use the fluent syntax to | ||
retrieve a collection of model objects that match your criteria and then |
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.
S: since collection usually refers to a MongoDB collection, using that word here (as a synonym of "group", from my understanding) could be misleading. You could change to:
retrieve a collection of model objects that match your criteria and then | |
retrieve multiple model objects that match your criteria and then |
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.
Will clarify the connection between MongoDB documents and a Laravel collection object.
retrieve a collection of model objects that match your criteria and then | ||
pass your updates to the ``update()`` method. | ||
|
||
The following example shows how to chain calls to retrieve a collection of |
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.
S: same comment regarding "collection" as above (unless you are referring to a whole MongoDB collection?)
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.
Thanks for pointing this out. I'll make sure to establish the connection between "documents" and "Laravel collection objects" when necessary, and otherwise use only one of those terms in a paragraph.
|
||
In this section, you can learn how to modify documents in your MongoDB | ||
collection from your Laravel application. Use update operations to modify | ||
existing documents or to insert a document if no documents match the search |
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.
S: [nit] to avoid repeating "documents":
existing documents or to insert a document if no documents match the search | |
existing documents or to insert a document if none match the search |
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.
LGTM!
|
||
If the operation fails, {+odm-short+} assigns the model instance a null value. | ||
|
||
The following example shows how to update a document to retrieve and update |
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.
S: Since this example demonstrates how to update documents by chaining methods together:
The following example shows how to update a document to retrieve and update | |
The following example shows how to chain methods to retrieve and update |
it by calling the ``update()`` method or other helper methods. | ||
|
||
The following example shows how to update a document by modifying an instance | ||
of the model and calling its ``save()`` method: |
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.
I was thinking of specifying which fields / values you're updating (venue
, ticketsSold
), but agreed that this could be repetitive and I think it's fine as is!
…operations-modify-documents
JIRA: https://jira.mongodb.org/browse/DOCSP-35947
Note for the reviewer:
This contains some updates to the insert documents section (added new fields to the sample doc).
This is one of three tickets to document the update operations. The other two are:
Staging:
https://preview-mongodbcchomongodb.gatsbyjs.io/laravel/DOCSP-35947-write-operations-modify-documents/fundamentals/write-operations/#modify-documents
Checklist