Skip to content

Commit 8918fbf

Browse files
committed
JM tech review 2
1 parent b08b7bf commit 8918fbf

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

source/run-command.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ statistics, initializing a replica set, or running an aggregation pipeline.
3636
that might not be available in the library.
3737

3838
If there are no available helpers in the library or the shell, you
39-
can use the ``db.runCommand()`` shell method.
39+
can use the ``db.runCommand()`` shell method or the library's
40+
``MongoDB\Database::command()`` method, which is described in this
41+
guide.
4042

4143
.. _php-execute-command:
4244

@@ -47,12 +49,11 @@ To run a database command, you must specify the command and any relevant
4749
parameters in a command document, then pass the command document to the
4850
``MongoDB\Database::command()`` method. Many database commands return
4951
multiple result documents, so the ``command()`` method returns a
50-
``Cursor`` object that you can iterate through.
52+
``MongoDB\Driver\Cursor`` object that you can iterate through.
5153

5254
The following code shows how you can use the ``command()``
5355
method on a :phpclass:`MongoDB\Database` instance to run the ``hello``
54-
command, which returns information about the current member's role in
55-
the replica set:
56+
command, which returns information about the server:
5657

5758
.. literalinclude:: /includes/write/run-command.php
5859
:language: php
@@ -66,7 +67,7 @@ parameters, see the :ref:`Additional Information section
6667

6768
.. note:: Read Preference
6869

69-
The ``command()`` method does not obey the read preference you might
70+
The ``command()`` method does not inherit the read preference you might
7071
have set on your ``Database`` instance elsewhere in your code. By
7172
default, ``command()`` uses the ``primary`` read preference.
7273

@@ -90,8 +91,12 @@ Response
9091
The ``command()`` method returns a ``Cursor`` object that contains
9192
the response from the database for the given command. Each database
9293
command performs a different function, so the response
93-
content can vary. Some command responses contain multiple result
94-
documents. In these situations, the library converts the cursor
94+
content can vary.
95+
96+
For commands that return a single result document,
97+
that result is available as the first and only document in the
98+
cursor. For commands that return multiple result
99+
documents, the library converts the cursor
95100
envelope in the raw command response, which includes the cursor ID and
96101
the first batch of results, into an iterable cursor.
97102

@@ -101,11 +106,6 @@ results or extracts the first and only document in the cursor. See the
101106
:ref:`php-addtl-info-runcommand` section of this guide to find a link to
102107
the full list of database commands.
103108

104-
If the number of documents in the command response is sufficiently large, you
105-
can run a :manual:`getMore </reference/command/getMore/>` command to
106-
retrieve the next batch of results from the cursor by using the cursor
107-
ID.
108-
109109
The raw command response contains the following fields:
110110

111111
.. list-table::

0 commit comments

Comments
 (0)