Skip to content

Commit ea89f82

Browse files
author
Kay Kim
committed
DOCS-12160: show dbs
1 parent d093012 commit ea89f82

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

source/mongo.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,20 @@ To display the database you are using, type ``db``:
215215
db
216216

217217
The operation should return ``test``, which is the default database.
218+
218219
To switch databases, issue the ``use <db>`` helper, as in the
219220
following example:
220221

221222
.. code-block:: javascript
222223

223224
use <database>
224225

225-
To list the available databases, use the helper ``show dbs``. See also
226-
:method:`db.getSiblingDB()` method to access a different database from
227-
the current database without switching your current database context
228-
(i.e. ``db``).
226+
See also :method:`db.getSiblingDB()` method to access a
227+
different database from the current database without switching your
228+
current database context (i.e. ``db``).
229+
230+
To list the databases available to the user, use the helper ``show
231+
dbs``. [#access]_
229232

230233
You can switch to non-existing databases. When you first store data in
231234
the database, such as by creating a collection, MongoDB creates the
@@ -268,6 +271,11 @@ For more documentation of basic MongoDB operations in the
268271
- :doc:`/tutorial/remove-documents`
269272
- :doc:`/reference/method`
270273

274+
.. [#access]
275+
If the deployment runs with access control, the operation
276+
returns different values based on user privileges. See
277+
:ref:`listDatabases Behavior <listDatabases-behavior>` for details.
278+
271279
Format Printed Results
272280
~~~~~~~~~~~~~~~~~~~~~~
273281

source/reference/command/listDatabases.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ Behavior
6060

6161
When :doc:`authentication </core/authentication>` is enabled:
6262

63+
.. admonition:: show dbs
64+
:class: note
65+
66+
For :binary:`~bin.mongo` shell version 4.0.6+ connected to earlier
67+
versions of MongoDB deployment (e.g. 3.6.10),
68+
69+
- If the user has :authaction:`listDatabases` action on the cluster
70+
resource, ``show dbs`` returns all databases.
71+
72+
- If the user does not have :authaction:`listDatabases` action on
73+
the cluster resource, ``show dbs`` returns only the databases for
74+
which the user has privileges (including those databases for which
75+
the user has privileges on specific collections).
76+
6377
.. tabs::
6478

6579
tabs:

source/tutorial/access-mongo-shell-help.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Database Help
4646
In the :binary:`~bin.mongo` shell:
4747

4848
- To see the list of databases on the server, use the ``show dbs``
49-
command:
49+
command: [#access]_
5050

5151
.. code-block:: javascript
5252

@@ -70,6 +70,12 @@ In the :binary:`~bin.mongo` shell:
7070

7171
db.updateUser
7272

73+
.. [#access]
74+
If the deployment runs with access control, the operation
75+
returns different values based on user privileges. See
76+
:ref:`listDatabases Behavior <listDatabases-behavior>` for details.
77+
78+
7379
.. _mongo-shell-help-collection:
7480

7581
Collection Help

0 commit comments

Comments
 (0)