Skip to content

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

Conversation

ccho-mongodb
Copy link
Contributor

@ccho-mongodb ccho-mongodb commented Apr 2, 2024

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

  • Add tests and ensure they pass
  • Add an entry to the CHANGELOG.md file
  • Update documentation for new features

@ccho-mongodb ccho-mongodb changed the title Docsp 35949 write operations upsert DOCSP-35949 write operations upsert Apr 2, 2024
Copy link
Contributor

@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.

lgtm with some comments/suggestions!

Comment on lines 277 to 278
- If the query matches documents, the ``update()`` method updates the matching
documents.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- If the query matches documents, the ``update()`` method updates the matching
documents.
- If the query matches documents, the ``update()`` method updates the matching
documents.

Comment on lines 286 to 287
method to perform an update or insert in a single operation. It also includes
example results in which it performs an insert.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Contributor Author

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.

Comment on lines 289 to 290
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
Copy link
Contributor

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

Comment on lines 291 to 292
example output shows the result if the match criteria passed to the
``where()`` method matches zero documents in the collection. Click the
Copy link
Contributor

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?

@ccho-mongodb ccho-mongodb marked this pull request as ready for review April 3, 2024 20:53
@ccho-mongodb ccho-mongodb requested a review from a team as a code owner April 3, 2024 20:53
@ccho-mongodb ccho-mongodb requested review from GromNaN and removed request for a team April 3, 2024 20:53
Comment on lines 265 to 272
.. code-block:: none
:emphasize-lines: 4
:copyable: false

YourModel::where(<match criteria>)
->update(
[<update data>],
['upsert' => true]);
Copy link
Member

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.

Suggested change
.. 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],
);

Copy link
Contributor Author

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?

Copy link
Member

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.

@ccho-mongodb ccho-mongodb requested a review from GromNaN April 4, 2024 19:10
@ccho-mongodb ccho-mongodb merged commit eb329d3 into mongodb:4.1-base-docs-write-operations Apr 8, 2024
@ccho-mongodb ccho-mongodb deleted the DOCSP-35949-write-operations-upsert branch April 8, 2024 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants