Skip to content

DOCSP-35972: Distinct values usage example #2846

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

DOCSP-35972: Distinct values usage example #2846

merged 7 commits into from
Apr 16, 2024

Conversation

norareidy
Copy link
Contributor

@norareidy norareidy commented Apr 10, 2024

Adds a usage example showing how to retrieve distinct field values.
JIRA - https://jira.mongodb.org/browse/DOCSP-35972
Staging - https://preview-mongodbnorareidy.gatsbyjs.io/laravel/DOCSP-35972/usage-examples/distinct/

Checklist

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

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.

approving with some non blocking comments, happy to take another look if need be!

The example calls the following methods on the ``Movie`` model:

- ``where()``: matches documents in which the value of the ``year`` field is ``1930``.
- ``select()``: retrieves the matching documents' ``imdb.rating`` field values.
Copy link
Contributor

Choose a reason for hiding this comment

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

S: is there a better field to select for than a numerical field? Like genre or director maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, changed to the directors field

Comment on lines 24 to 25
to the ``select()`` method. Then, call ``distinct()`` to return the unique field values of documents
that match the 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.

Suggested change
to the ``select()`` method. Then, call ``distinct()`` to return the unique field values of documents
that match the query filter.
to the ``select()`` method. Then, call ``distinct()`` to return the unique values of the selected field in documents
that match the query filter.

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

Could you make a note to revisit this page when working on the aggregation builder docs?

@ccho-mongodb
Copy link
Contributor

ccho-mongodb commented Apr 15, 2024

Could you make a note to revisit this page when working on the aggregation builder docs?

@GromNaN
Sure! What would you like to see on this page once the Aggregation Builder docs are completed?

@GromNaN
Copy link
Member

GromNaN commented Apr 15, 2024

Sure! What would you like to see on this page once the Aggregation Builder docs are completed?

It should demonstrate how to do almost the same result using an aggregation with a $group stage.

@ccho-mongodb ccho-mongodb merged commit 1a6b596 into mongodb:4.1 Apr 16, 2024
This was referenced Apr 16, 2024
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