-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DOCSP-35949 write operations upsert #2815
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-35949 write operations upsert #2815
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.
lgtm with some comments/suggestions!
- If the query matches documents, the ``update()`` method updates the matching | ||
documents. |
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.
- If the query matches documents, the ``update()`` method updates the matching | |
documents. | |
- If the query matches documents, the ``update()`` method updates the matching | |
documents. |
method to perform an update or insert in a single operation. It also includes | ||
example results in which it performs an insert. |
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.
method to perform an update or insert in a single operation. It also includes | |
example results in which it performs an insert. | |
method to perform an update or insert in a single operation. It also displays | |
the document produced when the operation results in an insert. |
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 on word choice ("displays"). Will reword to make it more concise.
The following example shows how to perform an update or insert in a single | ||
operation by passing the ``upsert`` option to the ``update()`` method. The |
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: remove this first sentence as it is repetitive with the prev paragraph
example output shows the result if the match criteria passed to the | ||
``where()`` method matches zero documents in the collection. Click the |
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: the second sentence is also slightly repetitive. Could you merge the two paragraphs instead?
.. code-block:: none | ||
:emphasize-lines: 4 | ||
:copyable: false | ||
|
||
YourModel::where(<match criteria>) | ||
->update( | ||
[<update data>], | ||
['upsert' => true]); |
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.
You can display valid PHP, that will not break the PHP code highlighter.
Also, our coding standard is to place the closing parenthesis on a new line when arguments are split by line.
.. code-block:: none | |
:emphasize-lines: 4 | |
:copyable: false | |
YourModel::where(<match criteria>) | |
->update( | |
[<update data>], | |
['upsert' => true]); | |
.. code-block:: php | |
:emphasize-lines: 4 | |
:copyable: false | |
YourModel::where(/* match criteria */) | |
->update( | |
[/* update data */], | |
['upsert' => true], | |
); |
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, I'll try it out!
Quick question: does the coding standard use trailing commas?
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.
Yes we use trailing comma when args are split per line.
…operations-upsert
JIRA - https://jira.mongodb.org/browse/DOCSP-35949
Staging - https://preview-mongodbcchomongodb.gatsbyjs.io/laravel/DOCSP-35949-write-operations-upsert/fundamentals/write-operations/#update-or-insert-in-a-single-operation
Note:
This PR is stacked on the Modify documents PR.
This is the second of three tickets that document the sections in "Fundamentals > Write Operations".
Relevant changes:
The remaining ticket is Update arrays.
Checklist