Skip to content

DOCSP-35973: Delete Many usage example #2837

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
merged 4 commits into from
Apr 15, 2024
Merged

DOCSP-35973: Delete Many usage example #2837

merged 4 commits into from
Apr 15, 2024

Conversation

norareidy
Copy link
Contributor

@norareidy norareidy commented Apr 9, 2024

Adds a usage example demonstrating how to delete multiple documents in a single operation
JIRA - https://jira.mongodb.org/browse/DOCSP-35973
Staging - https://preview-mongodbnorareidy.gatsbyjs.io/laravel/DOCSP-35973/usage-examples/deleteMany/

Checklist

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

@GromNaN GromNaN added the docs label Apr 10, 2024
Copy link
Contributor

@ccho-mongodb ccho-mongodb left a comment

Choose a reason for hiding this comment

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

LGTM, left a few suggestions.

Comment on lines 61 to 63
To learn more about deleting documents with {+odm-short+}, see the `Deleting Models
<https://laravel.com/docs/{+laravel-docs-version+}/eloquent#deleting-models>`__ section of the
Laravel documentation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion:
I think linking to the Fundamentals > Write Operations page "Delete Documents" section could be more directly helpful. Since that content hasn't been merged yet, I would suggest creating a cleanup task in the cleanup ticket.

:class: singlecol

You can delete multiple documents in a collection by calling the ``delete()`` method on an
Eloquent model or a query builder.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion:
The example currently shows it being chained to the results of the "where()" method rather than directly on the Eloquent model or by using the query builder DB facade.
I could be wrong, but I don't think it's a static method available on the model. I think it could be better to include a description of the way it's being called in the example, or to change the example to match one of the ways described.


- Uses the ``Movie`` Eloquent model to represent the ``movies`` collection in the
``sample_mflix`` database
- Deletes documents from the ``movies`` collection that match a query filter
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion:
Similar to prior feedback, I think printing the output should be mentioned or the code that prints should be hidden.


- ``where()``: matches documents in which the value of the ``year`` field is less than or
equal to ``1910``
- ``delete()``: deletes the retrieved documents
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion:

I think it could be helpful to add some information about the value printed even if it seems self-explanatory. E.g.
"The delete() method returns the number of documents successfully deleted"


.. tip::

To learn more about deleting documents with {+odm-short+}, see the :ref:`laravel-fundamentals-delete-documents`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: this PR will be merged after #2829

@norareidy norareidy marked this pull request as ready for review April 10, 2024 18:00
@norareidy norareidy requested a review from a team as a code owner April 10, 2024 18:00
@norareidy norareidy requested a review from GromNaN April 12, 2024 18:22
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

LGTM.

@ccho-mongodb ccho-mongodb merged commit 6cd08a1 into mongodb:4.1 Apr 15, 2024
This was referenced Apr 15, 2024
ccho-mongodb pushed a commit to ccho-mongodb/laravel-mongodb that referenced this pull request Apr 15, 2024
* DOCSP-35973: Delete Many usage example
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