Skip to content

Commit 5f72176

Browse files
authored
DOCSP-21628 Consistent Syntax Examples: L-P (#1489)
1 parent 124fe6c commit 5f72176

15 files changed

+465
-470
lines changed

source/reference/command/listCollections.txt

Lines changed: 86 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -22,100 +22,96 @@ Definition
2222
provides the :method:`db.getCollectionInfos()` and the
2323
:method:`db.getCollectionNames()` helper methods.
2424

25-
The command has the following form:
26-
27-
.. code-block:: javascript
28-
29-
{ listCollections: 1, filter: <document>, nameOnly: <boolean>, authorizedCollections: <boolean>, comment: <any> }
25+
Syntax
26+
------
3027

31-
The :dbcommand:`listCollections` command can take the following
32-
optional field:
28+
The command has the following syntax:
3329

30+
.. code-block:: javascript
3431

35-
.. list-table::
36-
:header-rows: 1
37-
:widths: 20 20 80
32+
db.runCommand(
33+
{
34+
listCollections: 1,
35+
filter: <document>,
36+
nameOnly: <boolean>,
37+
authorizedCollections: <boolean>,
38+
comment: <any>
39+
}
40+
)
41+
42+
Command Fields
43+
--------------
44+
45+
The command can take the following optional fields:
46+
47+
.. list-table::
48+
:header-rows: 1
49+
:widths: 20 20 80
50+
51+
* - Field
52+
- Type
53+
- Description
54+
55+
* - ``filter``
56+
- document
57+
- Optional. A query expression to filter the list of collections.
58+
59+
You can specify a query expression on any of the :ref:`fields
60+
returned <list-collection-output>` by :dbcommand:`listCollections`.
61+
62+
* - ``nameOnly``
63+
- boolean
64+
- Optional. A flag to indicate whether the command should return just the
65+
collection/view names and type or return both the name and other information.
66+
67+
Returning just the name and type (``view`` or ``collection``) does
68+
not take collection-level locks whereas returning full collection
69+
information locks each collection in the database.
70+
71+
The default value is ``false``.
72+
73+
.. note::
74+
75+
When ``nameOnly`` is ``true``, your ``filter`` expression can only
76+
filter based on a collection's name and type. No other fields are
77+
available.
78+
79+
.. versionadded:: 4.0
80+
81+
* - ``authorizedCollections``
82+
- boolean
83+
- Optional. A flag, when set to ``true`` and used with ``nameOnly: true``, that
84+
allows a user without the required privilege (i.e.
85+
:authaction:`listCollections` action on the database) to run the
86+
command when access control is enforced.
87+
88+
When both ``authorizedCollections`` and ``nameOnly`` options are set
89+
to true, the command returns only those collections for which the user
90+
has privileges. For example, if a user has :authaction:`find` action
91+
on specific collections, the command returns only those collections; or,
92+
if a user has :authaction:`find` or any other action, on the
93+
database resource, the command lists all collections in the database.
94+
95+
The default value is ``false``. That is, the user must have
96+
:authaction:`listCollections` action on the database to run the
97+
command.
98+
99+
For a user who has :authaction:`listCollections` action on the
100+
database, this option has no effect since the user has privileges to
101+
list the collections in the database.
102+
103+
When used without ``nameOnly: true``, this option has no effect.
104+
That is, the user must have the required privileges to run the
105+
command when access control is enforced. Otherwise, the user is
106+
unauthorized to run the command.
107+
108+
.. versionadded:: 4.0
109+
110+
* - ``comment``
111+
- any
112+
- .. include:: /includes/extracts/comment-content.rst
38113

39-
* - Field
40-
41-
- Type
42-
43-
- Description
44-
45-
* - ``filter``
46-
47-
- document
48-
49-
- Optional. A query expression to filter the list of collections.
50-
51-
You can specify a query expression on any of the :ref:`fields
52-
returned <list-collection-output>` by :dbcommand:`listCollections`.
53-
54-
55-
56-
* - ``nameOnly``
57-
58-
- boolean
59-
60-
- Optional. A flag to indicate whether the command should return just the
61-
collection/view names and type or return both the name and other information.
62-
63-
Returning just the name and type (``view`` or ``collection``) does
64-
not take collection-level locks whereas returning full collection
65-
information locks each collection in the database.
66-
67-
The default value is ``false``.
68-
69-
.. note::
70-
71-
When ``nameOnly`` is ``true``, your ``filter`` expression can only
72-
filter based on a collection's name and type. No other fields are
73-
available.
74-
75-
.. versionadded:: 4.0
76-
77-
78-
79-
* - ``authorizedCollections``
80-
81-
- boolean
82-
83-
- Optional. A flag, when set to ``true`` and used with ``nameOnly: true``, that
84-
allows a user without the required privilege (i.e.
85-
:authaction:`listCollections` action on the database) to run the
86-
command when access control is enforced.
87-
88-
When both ``authorizedCollections`` and ``nameOnly`` options are set
89-
to true, the command returns only those collections for which the user
90-
has privileges. For example, if a user has :authaction:`find` action
91-
on specific collections, the command returns only those collections; or,
92-
if a user has :authaction:`find` or any other action, on the
93-
database resource, the command lists all collections in the database.
94-
95-
The default value is ``false``. That is, the user must have
96-
:authaction:`listCollections` action on the database to run the
97-
command.
98-
99-
For a user who has :authaction:`listCollections` action on the
100-
database, this option has no effect since the user has privileges to
101-
list the collections in the database.
102-
103-
When used without ``nameOnly: true``, this option has no effect.
104-
That is, the user must have the required privileges to run the
105-
command when access control is enforced. Otherwise, the user is
106-
unauthorized to run the command.
107-
108-
.. versionadded:: 4.0
109-
110-
111-
* - ``comment``
112-
113-
- any
114-
115-
- .. include:: /includes/extracts/comment-content.rst
116-
117-
.. versionadded:: 4.4
118-
114+
.. versionadded:: 4.4
119115

120116
.. _listCollections-behavior:
121117

source/reference/command/listCommands.txt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,26 @@ listCommands
1010
:depth: 1
1111
:class: singlecol
1212

13+
Definition
14+
----------
15+
1316
.. dbcommand:: listCommands
1417

1518
The :dbcommand:`listCommands` command generates a list of all
1619
database commands implemented for the current :binary:`~bin.mongod` or
1720
:binary:`~bin.mongos` instance.
1821

19-
.. code-block:: javascript
22+
Syntax
23+
------
24+
25+
The command has the following syntax:
26+
27+
.. code-block:: javascript
2028

21-
db.runCommand( { listCommands: 1 } )
29+
db.runCommand(
30+
{
31+
listCommands: 1
32+
}
33+
)
2234

23-
.. slave-ok
35+
.. slave-ok

source/reference/command/listDatabases.txt

Lines changed: 63 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -20,82 +20,75 @@ Definition
2020
:dbcommand:`listDatabases` must run against the ``admin`` database,
2121
as in the following example:
2222

23-
.. code-block:: javascript
23+
Syntax
24+
------
2425

25-
db.adminCommand( { listDatabases: 1 } )
26+
.. code-block:: javascript
2627

27-
The value (e.g. ``1``) does not affect the output of the
28-
command.
28+
db.adminCommand(
29+
{
30+
listDatabases: 1
31+
}
32+
)
2933

30-
The :dbcommand:`listDatabases` command can take the following
31-
optional fields:
34+
The value (e.g. ``1``) does not affect the output of the
35+
command.
3236

37+
Command Fields
38+
--------------
3339

34-
.. list-table::
35-
:header-rows: 1
36-
:widths: 20 20 80
37-
38-
* - Field
39-
40-
- Type
41-
42-
- Description
43-
44-
* - ``filter``
45-
46-
- document
47-
48-
- Optional. A query predicate that determines which databases are listed.
49-
50-
You can specify a condition on any of the fields in the output of
51-
:dbcommand:`listDatabases`:
52-
53-
- ``name``
54-
55-
- ``sizeOnDisk``
56-
57-
- ``empty``
58-
59-
- ``shards``
60-
61-
62-
63-
* - ``nameOnly``
64-
65-
- boolean
66-
67-
- Optional. A flag to indicate whether the command should return just the
68-
database names, or return both database names and size information.
69-
70-
Returning size information requires locking each database one at a
71-
time, while returning only names does not require locking any database.
72-
73-
The default value is ``false``, so :dbcommand:`listDatabases` returns
74-
the name and size information of each database.
75-
76-
77-
78-
* - ``authorizedDatabases``
79-
80-
- boolean
81-
82-
- Optional. A flag that determines which databases are returned based on the
83-
user privileges when access control is enabled.
84-
85-
.. include:: /includes/extracts/listDatabases-auth-privileges.rst
86-
87-
For more information, see :ref:`listDatabases-behavior`.
88-
89-
.. versionadded:: 4.0.5
90-
91-
92-
* - ``comment``
93-
94-
- any
95-
96-
- .. include:: /includes/extracts/comment-content.rst
40+
The command can take the following optional fields:
41+
42+
.. list-table::
43+
:header-rows: 1
44+
:widths: 20 20 80
45+
46+
* - Field
47+
- Type
48+
- Description
49+
50+
* - ``filter``
51+
- document
52+
- Optional. A query predicate that determines which databases are listed.
53+
54+
You can specify a condition on any of the fields in the output of
55+
:dbcommand:`listDatabases`:
56+
57+
- ``name``
58+
59+
- ``sizeOnDisk``
60+
61+
- ``empty``
62+
63+
- ``shards``
64+
65+
* - ``nameOnly``
66+
- boolean
67+
- Optional. A flag to indicate whether the command should return just the
68+
database names, or return both database names and size information.
69+
70+
Returning size information requires locking each database one at a
71+
time, while returning only names does not require locking any database.
72+
73+
The default value is ``false``, so :dbcommand:`listDatabases` returns
74+
the name and size information of each database.
75+
76+
* - ``authorizedDatabases``
77+
- boolean
78+
- Optional. A flag that determines which databases are returned based on the
79+
user privileges when access control is enabled.
80+
81+
.. include:: /includes/extracts/listDatabases-auth-privileges.rst
82+
83+
For more information, see :ref:`listDatabases-behavior`.
84+
85+
.. versionadded:: 4.0.5
9786

98-
.. versionadded:: 4.4
87+
* - ``comment``
88+
- any
89+
- .. include:: /includes/extracts/comment-content.rst
90+
91+
.. versionadded:: 4.4
9992

10093
.. _listDatabases-behavior:
10194

source/reference/command/listIndexes.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Definition
2424
Syntax
2525
------
2626

27-
The command has the following form:
27+
The command has the following syntax:
2828

2929
.. code-block:: javascript
3030

@@ -37,9 +37,9 @@ The command has the following form:
3737
)
3838

3939
Command Fields
40-
~~~~~~~~~~~~~~
40+
--------------
4141

42-
``listIndexes`` takes the following fields:
42+
The command takes the following fields:
4343

4444
.. list-table::
4545
:header-rows: 1

0 commit comments

Comments
 (0)