-
Notifications
You must be signed in to change notification settings - Fork 52
DOCSP-30358: Run a Command Fundamentals page #702
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-30358: Run a Command Fundamentals page #702
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.
nicely done. mostly questions and suggestions
source/fundamentals/run-command.txt
Outdated
- ``command()``, which returns the command response as a | ||
``Document`` type. You can use this method with any database command. | ||
- ``runCursorCommand()``, which returns the command response as an iterable | ||
``RunCommandCursor`` type. You can use this method if your database 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.
S: "only if"?
``RunCommandCursor`` type. You can use this method if your database command | |
``RunCommandCursor`` type. You can use this method only if your database command |
source/fundamentals/run-command.txt
Outdated
``command()`` and ``runCursorCommand()`` do not obey the read | ||
preference you may have set on your ``Db`` object elsewhere in | ||
your code. You can set a read preference for command execution by |
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.
Q: What do they do instead?
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.
added default value
source/fundamentals/run-command.txt
Outdated
``command()`` and ``runCursorCommand()`` do not obey the read | ||
preference you may have set on your ``Db`` object elsewhere in | ||
your code. You can set a read preference for command execution by | ||
passing the relevant options object to either 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.
Q: What makes the objects "relevant"? Does each method accept a different object format?
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.
Yes, RunCommandOptions and RunCursorCommandOptions. I can clarify the pairs
Each method returns a ``Document`` object or a cursor that contains | ||
the response from the database after the command has been executed. Each |
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'm guessing this means command()
returns a Document
and runCursorCommand
returns a cursor. If so, can we clarify? By saying "Each method...", it sounds like each of the two methods will return one type or the other depending on some unspecified circumstance.
source/fundamentals/run-command.txt
Outdated
|
||
The following code shows how you can use the ``runCursorCommand()`` method to | ||
run the ``checkMetadataConsistency`` command on the ``testDB`` database | ||
and iterates through the results: |
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: "iterates", with an s, suggests it's the second thing "The following code" is doing, after "shows how you can use...". To me, it's more natural that the code is showing how you can do two things: 1) use the command and 2) iterate through the results, in which case it should be "iterate", with no s
and iterates through the results: | |
and iterate through the results: |
|
||
If you store the command response in a cursor, you see only the | ||
command result documents when you access the contents of the cursor. You won't | ||
see the ``ok``, ``operationTime``, and ``$clusterTime`` fields. |
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.
Q: is there a way to see this info when using a cursor?
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 don't think so. I can try printing the cursor a few different ways and see what happens, though.
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.
after some testing it seems like you cant, but I will follow up with DBX
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.
couple suggestions but lgtm otherwise
source/fundamentals/run-command.txt
Outdated
@@ -18,6 +18,13 @@ In this guide, you can learn how to run a database command with the | |||
administrative and diagnostic tasks, such as fetching server statistics, | |||
initializing a replica set, or running an aggregation pipeline. | |||
|
|||
.. important:: Use Driver Methods if Possible |
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.
.. important:: Use Driver Methods if Possible | |
.. important:: Prefer Driver Methods to Database Commands |
source/fundamentals/run-command.txt
Outdated
The driver provides wrapper methods that produce the same results as | ||
many database commands. We recommend that you check if there | ||
is a driver method available to perform your desired action before you | ||
execute a raw database 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.
Do you remember exactly why this is? Node isn't even statically typed like C#/Java. If you do, could be helpful to include.
The driver provides wrapper methods that produce the same results as | |
many database commands. We recommend that you check if there | |
is a driver method available to perform your desired action before you | |
execute a raw database command. | |
The {+driver-short+} provides wrapper methods for many database commands. | |
These wrapper methods... [advantages]. | |
If possible, use a driver method instead of a database command. |
* DOCSP-30358: run command fundamentals pg * add to tree * fix tree entry * add note and some fixes * move out of CURD * MW PR fixes 1 * MW PR fixes 2 (cherry picked from commit 12e4e60)
* DOCSP-30358: run command fundamentals pg * add to tree * fix tree entry * add note and some fixes * move out of CURD * MW PR fixes 1 * MW PR fixes 2
Pull Request Info
PR Reviewing Guidelines
JIRA - DOCSP-30358 and DOCSP-30119
Staging
Self-Review Checklist