-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DOCSP-35983: Run command usage example #2852
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-35983: Run command usage example #2852
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.
LGTM, but would like to take another look after updates related to the "sample_mflix" mention.
docs/usage-examples/runCommand.txt
Outdated
To run a command, call the ``command()`` method and specify the database command | ||
document inside the method call. This document includes the command name and |
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 "database command document" might not be a common term, so avoiding it could also avoid having to provide the explanation in the next sentence.
To run a command, call the ``command()`` method and specify the database command | |
document inside the method call. This document includes the command name and | |
To run a command, call the ``command()`` method and pass it a database command. |
docs/usage-examples/runCommand.txt
Outdated
- Creates a database connection instance to access the ``sample_mflix`` database | ||
- Specifies a command to retrieve a list of collections in the ``sample_mflix`` database | ||
- Prints the name of each ``sample_mflix`` collection |
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.
Issue:
There's no reference to "sample_mflix" in the code example.
Suggestion:
I think it could be good to either describe as the database configured for your "mongodb" connection or to add some information before this list that mentions that the mongodb connection is set to sample_mflix.
docs/usage-examples/runCommand.txt
Outdated
Run a Command | ||
============= | ||
|
||
You can run a command directly on a database by calling the ``command()`` |
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 it could be helpful to specify that it's a MongoDB command to avoid confusion, similar to how it's used in the admonition at the end of the page.
You can run a command directly on a database by calling the ``command()`` | |
You can run a MongoDB command directly on a database by calling the ``command()`` |
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 taking into account the comments made by @ccho-mongodb
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
// phpcs:disable | ||
// begin-command | ||
$cursor = DB::connection('mongodb') | ||
->command(['listCollections' => 1]); | ||
|
||
foreach ($cursor as $coll) { | ||
echo $coll['name'] . '<br>'; | ||
} | ||
|
||
// end-command | ||
// phpcs:enable |
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 for @GromNaN:
I'm not able to get the tests to pass since printing any output causes a CI test failure. Is there a way to keep the output code and pass the CI tests?
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 fixed the test by adding $this->expectOutputRegex('/<br>/');
The phpcs:disable
statement was not necessary.
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
// phpcs:disable | ||
// begin-command | ||
$cursor = DB::connection('mongodb') | ||
->command(['listCollections' => 1]); | ||
|
||
foreach ($cursor as $coll) { | ||
echo $coll['name'] . '<br>'; | ||
} | ||
|
||
// end-command | ||
// phpcs:enable |
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 fixed the test by adding $this->expectOutputRegex('/<br>/');
The phpcs:disable
statement was not necessary.
Thanks for fixing the test -- I guess I just need a test to match on the output to prevent the "Risky" classification? |
JIRA - https://jira.mongodb.org/browse/DOCSP-35983
Staging - https://preview-mongodbnorareidy.gatsbyjs.io/laravel/DOCSP-35983/usage-examples/runCommand/
Checklist