Skip to content

Commit a4325b1

Browse files
mungitoperritojeff-allen-mongo
authored andcommitted
DOCSP-19204 Add mongosh help page
1 parent 4040547 commit a4325b1

File tree

3 files changed

+155
-2
lines changed

3 files changed

+155
-2
lines changed

source/help.txt

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
.. _mongosh-help:
2+
3+
=======================
4+
Access ``mongosh`` Help
5+
=======================
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: twocols
14+
15+
This document provides a brief overview of the help available in
16+
:binary:`~bin.mongosh`.
17+
18+
.. _mongosh-help-command-line:
19+
20+
Command Line Help
21+
-----------------
22+
23+
To see the options for running the :binary:`~bin.mongosh` executable
24+
and connecting to a deployment, use the :option:`--help <mongosh
25+
--help>` option from the command line:
26+
27+
.. code-block:: bash
28+
29+
mongosh --help
30+
31+
``mongosh`` Shell Help
32+
----------------------
33+
34+
To see the help available in the :binary:`~bin.mongosh` console, type
35+
``help`` inside a running :binary:`~bin.mongosh` console:
36+
37+
.. code-block:: javascript
38+
39+
help
40+
41+
.. _mongo-shell-help-db:
42+
43+
Database Help
44+
-------------
45+
46+
You can view database level information from inside the
47+
:binary:`~bin.mongosh` console:
48+
49+
- By default :binary:`~bin.mongosh` shows the current database in the
50+
prompt. You can also see the current database by running the ``db``
51+
command:
52+
53+
.. code-block:: javascript
54+
55+
db
56+
57+
- To see the list of databases available to you on the server, use the
58+
``show dbs`` command:
59+
60+
.. code-block:: javascript
61+
62+
show dbs
63+
64+
``show databases`` is an alias for ``show dbs``.
65+
66+
.. tip::
67+
68+
The list of databases will change depending on your access
69+
authorizations. For more information on access restrictions for
70+
viewing databases, see :dbcommand:`listDatabases`.
71+
72+
- To see help for the available :manual:`database methods
73+
</reference/method/js-database/>` you can use with the ``db`` object,
74+
run :method:`db.help()`:
75+
76+
.. code-block:: javascript
77+
78+
db.help()
79+
80+
.. _mongosh-help-collection:
81+
82+
Collection Help
83+
---------------
84+
85+
You can view collection level information from inside the
86+
:binary:`~bin.mongosh` console.
87+
88+
These help methods accept a collection name, ``<collection>``, but you
89+
can also use the generic term, "collection", or even a collection that
90+
does not exist.
91+
92+
- By default :binary:`~bin.mongosh` shows the current database in the
93+
prompt. To see the list of collections in the current database, use
94+
the ``show collections`` command:
95+
96+
.. code-block:: javascript
97+
98+
show collections
99+
100+
- To see the help for methods available on collection objects
101+
use ``db.<collection>.help()`` method:
102+
103+
.. code-block:: javascript
104+
105+
db.collection.help()
106+
107+
- To see the help for a particular method, use
108+
``db.<collection>.<method>.help()``:
109+
110+
.. code-block:: javascript
111+
112+
db.collection.getIndexes.help()
113+
114+
115+
.. _mongosh-help-cursor:
116+
117+
Cursor Help
118+
-----------
119+
120+
Use :ref:`cursor methods <mongosh-cursor-methods>` to modify
121+
:ref:`read operations <read-operations-queries>` that use
122+
:method:`~db.collection.find()`.
123+
124+
- To list the available modifier and cursor handling methods, use the
125+
``db.collection.find().help()`` command:
126+
127+
.. code-block:: javascript
128+
129+
db.collection.find().help()
130+
131+
This help call accepts a collection name, ``<collection>``, but you
132+
can also use the generic term, "collection", or even a collection which
133+
does not exist.
134+
135+
Some useful methods for handling cursors are:
136+
137+
- :method:`~cursor.hasNext()` checks if the cursor has more documents.
138+
139+
- :method:`~cursor.next()` returns the next document and moves the
140+
cursor position forward by one.
141+
142+
- :method:`forEach(\<function\>) <cursor.forEach()>` applies the
143+
``<function>`` to each document returned by the cursor.
144+
145+
For a list of available cursor methods, see :ref:`js-query-cursor-methods`.
146+
147+
.. seealso::
148+
149+
- :ref:`run-commands` provides guidance on how to use
150+
:binary:`~bin.mongosh`.
151+
- :ref:`mdb-shell-methods` lists available methods.
152+

source/index.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ Learn More
9494
:titlesonly:
9595

9696
/install
97-
/reference/compatibility
9897
/connect
9998
/field-level-encryption
10099
/logs
101100
/run-commands
102101
/snippets
103102
/write-scripts
104103
/reference
104+
/help
105+
/reference/compatibility
105106
/changelog
106107

source/reference/methods.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ Cursor Methods
446446

447447
.. arrayAccess
448448

449-
* - ``cursor.batchSize()``
449+
* - :method:`cursor.batchSize()`
450450
- Controls the number of documents MongoDB will return to the
451451
client in a single network message.
452452

0 commit comments

Comments
 (0)