Skip to content

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

Merged
merged 13 commits into from
Apr 19, 2024
Merged

DOCSP-35983: Run command usage example #2852

merged 13 commits into from
Apr 19, 2024

Conversation

norareidy
Copy link
Contributor

@norareidy norareidy commented Apr 12, 2024

JIRA - https://jira.mongodb.org/browse/DOCSP-35983
Staging - https://preview-mongodbnorareidy.gatsbyjs.io/laravel/DOCSP-35983/usage-examples/runCommand/

Checklist

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

Copy link
Contributor

@ccho-mongodb ccho-mongodb left a 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.

Comment on lines 10 to 11
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
Copy link
Contributor

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.

Suggested change
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.

Comment on lines 19 to 21
- 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
Copy link
Contributor

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.

Run a Command
=============

You can run a command directly on a database by calling the ``command()``
Copy link
Contributor

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.

Suggested change
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()``

@GromNaN GromNaN added the docs label Apr 15, 2024
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 taking into account the comments made by @ccho-mongodb

@ccho-mongodb ccho-mongodb self-requested a review April 17, 2024 18:52
Copy link
Contributor

@ccho-mongodb ccho-mongodb left a comment

Choose a reason for hiding this comment

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

LGTM

@ccho-mongodb ccho-mongodb marked this pull request as ready for review April 17, 2024 19:12
@ccho-mongodb ccho-mongodb requested a review from a team as a code owner April 17, 2024 19:12
Comment on lines 19 to 29
// phpcs:disable
// begin-command
$cursor = DB::connection('mongodb')
->command(['listCollections' => 1]);

foreach ($cursor as $coll) {
echo $coll['name'] . '<br>';
}

// end-command
// phpcs:enable
Copy link
Contributor

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?

Copy link
Member

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.

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

Comment on lines 19 to 29
// phpcs:disable
// begin-command
$cursor = DB::connection('mongodb')
->command(['listCollections' => 1]);

foreach ($cursor as $coll) {
echo $coll['name'] . '<br>';
}

// end-command
// phpcs:enable
Copy link
Member

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.

@ccho-mongodb
Copy link
Contributor

Thanks for fixing the test -- I guess I just need a test to match on the output to prevent the "Risky" classification?

@ccho-mongodb ccho-mongodb merged commit 839b411 into mongodb:4.1 Apr 19, 2024
This was referenced Apr 19, 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.

3 participants