Skip to content

DOCSP-35976: Delete One usage example #2821

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 13 commits into from
Apr 8, 2024
Merged

DOCSP-35976: Delete One usage example #2821

merged 13 commits into from
Apr 8, 2024

Conversation

norareidy
Copy link
Contributor

@norareidy norareidy commented Apr 3, 2024

This PR adds a usage example page demonstrating how to delete one document from a collection

JIRA - https://jira.mongodb.org/browse/DOCSP-35976
Staging - https://preview-mongodbnorareidy.gatsbyjs.io/laravel/DOCSP-35976-staging/usage-examples/deleteOne/

Checklist

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

Copy link
Contributor

@jordan-smith721 jordan-smith721 left a comment

Choose a reason for hiding this comment

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

LGTM w/ a few suggestions

You can delete a document in a collection by retrieving a single document and calling
the ``delete()`` method on an Eloquent model or a query builder.

Pass a query filter to the ``where()`` method, sort the matching documents, and call the
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Is "query filter" defined somewhere in these docs yet? If so, it might be good to link to that somewhere. (ie: "For more information about query filters, see ... ")

Comment on lines 23 to 25
Pass a query filter to the ``where()`` method, sort the matching documents, and call the
``first()`` method to retrieve only the first document. Then, delete this matching document
by calling the ``delete()`` method.
Copy link
Contributor

@jordan-smith721 jordan-smith721 Apr 3, 2024

Choose a reason for hiding this comment

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

I think this paragraph could be more clear if it was presented as a list:

Suggested change
Pass a query filter to the ``where()`` method, sort the matching documents, and call the
``first()`` method to retrieve only the first document. Then, delete this matching document
by calling the ``delete()`` method.
Perform the following steps to delete a document:
1. Pass a query filter to the ``where()`` method
2. Sort the matching documents
3. Call the ``first()`` method to retrieve only the first document
4. Delete this matching document by calling the ``delete()`` method.

Although, looking at the update usage example page, it looks like that might not be inline with the formatting being used in these docs. An alternative suggestion would be:

Suggested change
Pass a query filter to the ``where()`` method, sort the matching documents, and call the
``first()`` method to retrieve only the first document. Then, delete this matching document
by calling the ``delete()`` method.
To delete a document, pass a query filter to the ``where()`` method, sort the matching documents, and call the
``first()`` method to retrieve only the first document. Then, delete this matching document
by calling the ``delete()`` method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Took your second suggestion!

Comment on lines 32 to 34
- Uses the ``Movie`` Eloquent model to represent the ``movies`` collection in the
``sample_mflix`` database.
- Deletes a document from the ``movies`` collection that matches 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.

I don't think we should have a period on these since they're not full sentences (subject is in the intro)

Suggested change
- Uses the ``Movie`` Eloquent model to represent the ``movies`` collection in the
``sample_mflix`` database.
- Deletes a document from the ``movies`` collection that matches a query filter.
- Uses the ``Movie`` Eloquent model to represent the ``movies`` collection in the
``sample_mflix`` database.
- Deletes a document from the ``movies`` collection that matches 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.

Feel free to double-check me on this one - I'm not 100% sure if we still consider it a fragment with the subject implied in the intro

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed - I think these are all fragments. Fixed!

@norareidy norareidy marked this pull request as ready for review April 3, 2024 19:57
@norareidy norareidy requested a review from a team as a code owner April 3, 2024 19:57
@norareidy norareidy requested a review from jmikola April 3, 2024 19:57
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.

I think we also need an example with the query builder, without retrieving the document.

@norareidy
Copy link
Contributor Author

I think we also need an example with the query builder, without retrieving the document.

I created a ticket to add query builder examples to these pages in the future

@norareidy norareidy requested a review from GromNaN April 4, 2024 15:23
@norareidy norareidy merged commit 10f44bf into mongodb:4.1 Apr 8, 2024
@norareidy norareidy deleted the DOCSP-35976-delete-one branch April 8, 2024 20:42
This was referenced Apr 8, 2024
ccho-mongodb pushed a commit to ccho-mongodb/laravel-mongodb that referenced this pull request Apr 15, 2024
Adds a usage example page demonstrating how to delete one document from a collection
---------

Co-authored-by: norareidy <norareidy@users.noreply.github.com>
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.

4 participants