Skip to content

Commit f153da3

Browse files
(DOCSP-10727): Add topic for embedded mdb shell (#266)
1 parent 5cce6d5 commit f153da3

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

source/embedded-shell.txt

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
.. _embedded-mongodb-shell:
2+
3+
======================
4+
Embedded MongoDB Shell
5+
======================
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
Starting in version 1.22, |compass| contains an embedded
16+
`MongoDB Shell <https://docs.mongodb.com/mongodb-shell/>`__. The
17+
MongoDB Shell is a fully functional JavaScript environment for
18+
interacting with MongoDB deployments. You can use the MongoDB Shell to
19+
test queries and operations directly with your database.
20+
21+
Open the Embedded MongoDB Shell
22+
-------------------------------
23+
24+
To open the embedded MongoDB Shell, click :guilabel:`MongoSH Beta`
25+
along the bottom of |compass|.
26+
27+
Use the Embedded MongoDB Shell
28+
------------------------------
29+
30+
When you initially open the MongoDB Shell, it connects to the
31+
``test`` database. To switch to a different database, run
32+
the following command in the MongoDB Shell:
33+
34+
.. code-block:: sh
35+
36+
use <database name>
37+
38+
To run an operation in the embedded MongoDB Shell, type the operation
39+
into the shell and press :guilabel:`Enter`.
40+
41+
.. example::
42+
43+
.. code-block:: sh
44+
45+
db.employees.find( { "last_name": "Smith" } )
46+
47+
.. seealso::
48+
49+
:manual:`db.collection.find()
50+
</reference/method/db.collection.find>`
51+
52+
Multi-Line Operations in the Embedded MongoDB Shell
53+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54+
55+
To write an operation that spans multiple lines in the embedded
56+
MongoDB Shell, press :guilabel:`Shift + Enter` to begin the next
57+
line of code.
58+
59+
When you are finished writing your operation, press :guilabel:`Enter`
60+
to run it.
61+
62+
.. example::
63+
64+
.. code-block:: javascript
65+
66+
db.employees.aggregate( [ // press Shift + Enter
67+
{ $match: { "last_name": "Smith" } } // press Shift + Enter
68+
] ) // Press Enter
69+
70+
.. seealso::
71+
72+
:pipeline:`$match`
73+
74+
Learn More
75+
~~~~~~~~~~
76+
77+
The following links direct to the
78+
`MongoDB Shell Documentation
79+
<https://docs.mongodb.com/mongodb-shell/>`__, which contains more
80+
complete reference for the MongoDB Shell, including syntax and
81+
behaviors.
82+
83+
- Learn how to
84+
`Perform CRUD Operations in the MongoDB Shell
85+
<https://docs.mongodb.com/mongodb-shell/crud>`__.
86+
87+
- Learn how to
88+
`Run Aggregation Pipelines in the MongoDB Shell
89+
<https://docs.mongodb.com/mongodb-shell/run-agg-pipelines>`__.
90+
91+
- See a complete list of
92+
`Available MongoDB Shell Methods
93+
<https://docs.mongodb.com/mongodb-shell/reference/methods>`__.

source/index.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ suit your needs.
170170
/manage-data
171171
/aggregation-pipeline-builder
172172
/import-export
173+
/embedded-shell
173174
/troubleshooting
174175
/faq
175176
/learn-more

0 commit comments

Comments
 (0)