-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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-35970: Find one usage example #2768
Conversation
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.
a few small things, let me know if you have any questions about my comments!
docs/usage-examples/findOne.txt
Outdated
:term:`natural order` in the database or according to the sort order specified by 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.
:term:`natural order` in the database or according to the sort order specified by the | |
``orderBy()`` method. | |
: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.
left some non-blocking comments, Can leave another review if you prefer though!
docs/usage-examples/findOne.txt
Outdated
You can retrieve a single document from a collection by chaining the ``where()`` and | ||
``first()`` methods on an Eloquent model or a query builder. | ||
|
||
Pass a query filter to the ``where()`` method and call the ``first()`` method to return |
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.
Pass a query filter to the ``where()`` method and call the ``first()`` method to return | |
Pass a query filter to the ``where()`` method and then call the ``first()`` method to return |
docs/usage-examples/findOne.txt
Outdated
- Defines a query filter that matches documents in which the value of the ``directors`` field | ||
is ``"Rob Reiner"`` |
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.
S: I think the directors
field is an array-valued field
- Defines a query filter that matches documents in which the value of the ``directors`` field | |
is ``"Rob Reiner"`` | |
- Defines a query filter that matches documents in which the value of the ``directors`` field | |
includes ``"Rob Reiner"`` |
docs/usage-examples/findOne.txt
Outdated
class MovieController | ||
{ | ||
public function show() | ||
{ | ||
$movie = Movie::where('directors', 'Rob Reiner') | ||
->orderBy('_id') | ||
->first(); | ||
|
||
return view('browse_movies', [ | ||
'movie' => $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.
S: move into files and include (applies to all code examples)
…avel-mongodb into DOCSP-35970-find-one-usage
->orderBy('_id') | ||
->first(); | ||
|
||
print_r($movie->toJson()); |
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.
Do we really want to display the results with print_r
? That is not very compatible with PHPUnit.
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.
How would you prefer to display the results? Originally I used a view, but I changed it to print_r
for simplicity
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.
Since it's a simple string, I modified to use echo
.
…avel-mongodb into DOCSP-35970-find-one-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. With a simplification of the model. Maybe sharing the same model class for all the find examples would be a good idea.
->orderBy('_id') | ||
->first(); | ||
|
||
print_r($movie->toJson()); |
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.
Since it's a simple string, I modified to use echo
.
|
||
$this->assertInstanceOf(Movie::class, $movie); | ||
|
||
$this->expectOutputRegex('^{"_id":"[a-z0-9]{24}","title":"The Shawshank Redemption","directors":["Frank Darabont","Rob Reiner"]}$'); |
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.
Adding assertions on output.
aad93f7
to
bf98e98
Compare
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
JIRA - https://jira.mongodb.org/browse/DOCSP-35970
Staging - https://preview-mongodbnorareidy.gatsbyjs.io/laravel/DOCSP-35970-staging/usage-examples/findOne/
Checklist