@@ -22,100 +22,96 @@ Definition
22
22
provides the :method:`db.getCollectionInfos()` and the
23
23
:method:`db.getCollectionNames()` helper methods.
24
24
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
+ ------
30
27
31
- The :dbcommand:`listCollections` command can take the following
32
- optional field:
28
+ The command has the following syntax:
33
29
30
+ .. code-block:: javascript
34
31
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
38
113
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
119
115
120
116
.. _listCollections-behavior:
121
117
0 commit comments