File tree Expand file tree Collapse file tree 13 files changed +87
-31
lines changed Expand file tree Collapse file tree 13 files changed +87
-31
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,4 @@ on the command line or by specifying a :ref:`.js file
13
13
14
14
.. note :: Legacy Shell Configuration
15
15
16
- The legacy :binary: `~bin.mongo ` shell used a configuration file called
17
- ``.mongorc.js ``. If :binary: `mongosh ` detects this file on startup and
18
- ``.mongoshrc.js `` is not present, :binary: `mongosh ` does not load the legacy
19
- ``.mongorc.js `` file, and suggests renaming ``.mongorc.js `` to
20
- ``.mongoshrc.js ``.
16
+ .. include :: /includes/legacy/legacy-shell-configuration.rst
Original file line number Diff line number Diff line change
1
+ For commands whose output includes ``{ ok: 0 } ``, ``mongosh `` returns a
2
+ consistent exception and omits the server raw output. The legacy
3
+ ``mongo `` shell returns output that varies for each command.
Original file line number Diff line number Diff line change
1
+ MongoDB stores data using :manual: `BSON </reference/bson-types> `, which
2
+ supports additional data types that aren't available in :term: `JSON `.
3
+ The ``mongosh `` shell has better data type support for
4
+ :ecosystem: `drivers </drivers> ` than the legacy ``mongo `` shell.
Original file line number Diff line number Diff line change
1
+ The legacy ``mongo `` shell cannot access a script's file name or
2
+ directory in the ``load() `` method.
Original file line number Diff line number Diff line change
1
+ The ``mongosh `` shell returns output that differs from the legacy
2
+ ``mongo `` shell. If you have scripts that require the output to be
3
+ formatted in a similar way to the legacy ``mongo `` shell, try
4
+ reformatting the ``mongosh `` output with :ref: `EJSON.stringify()
5
+ <mongosh-ejson-stringify>`.
Original file line number Diff line number Diff line change
1
+ By default, retryable writes are:
2
+
3
+ - enabled in :binary: `mongosh `
4
+ - disabled in the legacy ``mongo `` shell
5
+
6
+ To disable retryable writes, use :option: `--retryWrites=false <mongosh
7
+ --retryWrites> `.
Original file line number Diff line number Diff line change
1
+ The legacy ``mongo `` shell uses a configuration file named
2
+ ``.mongorc.js ``.
3
+
4
+ If :binary: `mongosh ` finds ``.mongorc.js `` on startup but doesn't find
5
+ ``.mongoshrc.js ``, ``mongosh `` doesn't load the legacy ``.mongorc.js ``
6
+ file and states you should rename ``.mongorc.js `` to ``.mongoshrc.js ``.
Original file line number Diff line number Diff line change @@ -240,3 +240,51 @@ Limitations on Database Calls
240
240
241
241
.. include:: /includes/fact-call-limitations.rst
242
242
243
+ Command Exceptions
244
+ ------------------
245
+
246
+ .. include:: /includes/legacy/legacy-command-exceptions.rst
247
+
248
+ For details, see :ref:`run-commands`.
249
+
250
+ Shell Configuration
251
+ -------------------
252
+
253
+ .. include:: /includes/legacy/legacy-shell-configuration.rst
254
+
255
+ For details, see :ref:`mongoshrc-js`.
256
+
257
+ Data Types
258
+ ----------
259
+
260
+ .. include:: /includes/legacy/legacy-data-types.rst
261
+
262
+ For details, see :ref:`mongo-shell-data-types`.
263
+
264
+ Methods
265
+ -------
266
+
267
+ .. include:: /includes/legacy/legacy-load-method.rst
268
+
269
+ For details, see :ref:`load() <mongosh-native-method-load>`.
270
+
271
+ Retryable Writes
272
+ ----------------
273
+
274
+ .. include:: /includes/legacy/legacy-retryable-writes.rst
275
+
276
+ For details, see :option:`--retryWrites`.
277
+
278
+ Legacy Output
279
+ -------------
280
+
281
+ .. include:: /includes/legacy/legacy-output.rst
282
+
283
+ For details, see :ref:`mongosh-ejson-stringify-legacy-output`.
284
+
285
+ Code Snippets
286
+ -------------
287
+
288
+ Working with code snippets is different for the legacy ``mongo`` shell.
289
+
290
+ For details, see :ref:`snip-get-help`.
Original file line number Diff line number Diff line change
1
+ .. _mongo-shell-data-types:
2
+
1
3
==========
2
4
Data Types
3
5
==========
@@ -12,12 +14,7 @@ Data Types
12
14
13
15
.. _mongo-shell-data-type:
14
16
15
- MongoDB Server stores data using the
16
- :manual:`BSON </reference/bson-types>` format which supports some
17
- additional data types that are not available using the :term:`JSON`
18
- format. Compared to the legacy ``mongo`` shell, MongoDB Shell
19
- (``mongosh``) has type handling which is better aligned with the
20
- default types used by the MongoDB :ecosystem:`drivers </drivers>`.
17
+ .. include:: /includes/legacy/legacy-data-types.rst
21
18
22
19
This document highlights changes in type usage between ``mongosh`` and
23
20
the legacy ``mongo`` shell. See the
Original file line number Diff line number Diff line change @@ -613,12 +613,12 @@ The output is:
613
613
}
614
614
]
615
615
616
+ .. _mongosh-ejson-stringify-legacy-output:
617
+
616
618
Legacy ``tojsononeline()``
617
619
~~~~~~~~~~~~~~~~~~~~~~~~~~
618
620
619
- ``mongosh`` formats query output differently than the deprecated
620
- ``mongo`` shell. You may have scripts which rely on the old format. To
621
- reformat ``mongosh`` output on a single line, use ``EJSON.stringify()``.
621
+ .. include:: /includes/legacy/legacy-output.rst
622
622
623
623
Run a sample query in ``mongosh`` and ``mongo`` to see the different
624
624
formats.
Original file line number Diff line number Diff line change @@ -883,8 +883,7 @@ Native Methods
883
883
script, respectively. The returned values are always absolute
884
884
paths.
885
885
886
- In the legacy shell, you cannot not access the script's file name
887
- or directory using the ``load()`` method.
886
+ .. include:: /includes/legacy/legacy-load-method.rst
888
887
889
888
* - .. _mongosh-native-method-print:
890
889
Original file line number Diff line number Diff line change @@ -562,10 +562,9 @@ Session Options
562
562
563
563
.. option:: --retryWrites
564
564
565
- Enables :ref:`retryable-writes`. Retryable writes are enabled by
566
- default in :binary:`mongosh`. Retryable writes are disabled by
567
- default in the legacy :binary:`mongo` shell. To disable retryable
568
- writes, use :option:`--retryWrites=false <mongosh --retryWrites>`.
565
+ Enables :ref:`retryable-writes`.
566
+
567
+ .. include:: /includes/legacy/legacy-retryable-writes.rst
569
568
570
569
For more information on sessions, see :ref:`sessions`.
571
570
Original file line number Diff line number Diff line change @@ -108,20 +108,10 @@ You can also terminate a script from within the script code by calling the
108
108
``exit(<code>)`` command. For more information, refer to
109
109
:ref:`Terminate a Script on Error <mongosh-terminate-script>`.
110
110
111
-
112
111
Command Exceptions
113
112
------------------
114
113
115
- In scenarios where the output of a command includes ``{ ok: 0 }``,
116
- ``mongosh`` throws an exception and does not return the raw output from
117
- the server.
118
-
119
- .. note::
120
-
121
- In the legacy ``mongo`` shell, when a command's output included ``{
122
- ok: 0 }``, the behavior differs between commands. ``mongosh``
123
- provides consistent behavior by always throwing an exception in these
124
- scenarios.
114
+ .. include:: /includes/legacy/legacy-command-exceptions.rst
125
115
126
116
Clear the ``mongosh`` Console
127
117
-----------------------------
You can’t perform that action at this time.
0 commit comments