-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DOCSP-35977: Find multiple usage example #2833
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-35977: Find multiple usage example #2833
Conversation
…y/laravel-mongodb into DOCSP-35977-find-multiple-usage
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, a few questions and suggestions!
docs/usage-examples/find.txt
Outdated
// Results are truncated | ||
|
||
{ | ||
"_id": "...", | ||
"plot": "The economic and cultural growth of Colorado spanning two centuries from the mid-1700s to the late-1970s.", | ||
"genres": [ | ||
"Action", | ||
"Adventure", | ||
"Drama" | ||
], | ||
"runtime": 1256, | ||
... | ||
"title": "Centennial", | ||
... |
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.
Suggestion:
I think showing the expanded "title", "runtime", and "_id" fields could make the output easier to read and would be sufficient to help the reader understand the query filter and sort order. I think the rest could be hidden with "..."
Perhaps you'd want matches that also aren't easy to mistake for
another more popular title such as "Taken" since the "runtime" field could be a point of confusion.
Another solution could be to avoid using the "_id" sort and instead using the "runtime" value so that you could omit the "_id" field.
docs/usage-examples/find.txt
Outdated
.. tip:: | ||
|
||
To learn more about retrieving documents with {+odm-short+}, see the | ||
:ref:`laravel-fundamentals-retrieve` guide |
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.
:ref:`laravel-fundamentals-retrieve` guide | |
:ref:`laravel-fundamentals-retrieve` guide. |
docs/usage-examples/find.txt
Outdated
|
||
.. tip:: | ||
|
||
To learn more about retrieving documents with {+odm-short+}, see 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.
I think "where()" is one of many methods you can chain to the model class. Maybe this sentence could be modified to indicate there are other ways of retrieving documents.
"To learn about other ways to retrieve documents..."
- Uses the ``Movie`` Eloquent model to represent the ``movies`` collection in the | ||
``sample_mflix`` database | ||
- Retrieves documents from the ``movies`` collection that match a query filter | ||
|
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.
Suggestion:
The example shows code to print out the retrieved documents, so I think it should either be mentioned or the code should be omitted.
|
||
// end-find | ||
|
||
$this->assertInstanceOf(Movie::class, $movie); |
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.
Suggestion:
I think $movie hasn't been declared, so I would omit this assertion, or place it in a loop similar to lines 27-29.
docs/usage-examples/find.txt
Outdated
Pass a query filter to the ``where()`` method to retrieve documents that meet a | ||
set of criteria. MongoDB returns the matching documents according to their | ||
:term:`natural order` in the database or according to the sort order that you can specify | ||
by using the ``orderBy()`` method. |
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.
Question:
Can you access the cursor by chaining the "cursor()" method like this? If that's the preferred method of retrieving multiple results, I think we should show that.
…y/laravel-mongodb into DOCSP-35977-find-multiple-usage
Co-authored-by: Jérôme Tamarelle <[email protected]>
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.
], | ||
[ | ||
'title' => 'Basketball', | ||
'runtime' => 600, |
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.
I've added an item with runtime <= 900 for the test to be complete.
Adds a usage example showing how to retrieve multiple documents.
JIRA - https://jira.mongodb.org/browse/DOCSP-35977
Staging -
https://preview-mongodbcchomongodb.gatsbyjs.io/laravel/DOCSP-35977-ccho/usage-examples/find/
Checklist