Skip to content

Commit 4f21a38

Browse files
jason-price-mongodbjason-price-mongodb
andauthored
DOCSP-34087-compatibility-updates (#352)
* DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates * DOCSP-34087-compatibility-updates --------- Co-authored-by: jason-price-mongodb <[email protected]>
1 parent 5473257 commit 4f21a38

13 files changed

+87
-31
lines changed

source/includes/fact-mongoshrc-loading.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,4 @@ on the command line or by specifying a :ref:`.js file
1313

1414
.. note:: Legacy Shell Configuration
1515

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
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
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.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
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.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The legacy ``mongo`` shell cannot access a script's file name or
2+
directory in the ``load()`` method.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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>`.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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>`.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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``.

source/reference/compatibility.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,51 @@ Limitations on Database Calls
240240

241241
.. include:: /includes/fact-call-limitations.rst
242242

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`.

source/reference/data-types.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _mongo-shell-data-types:
2+
13
==========
24
Data Types
35
==========
@@ -12,12 +14,7 @@ Data Types
1214

1315
.. _mongo-shell-data-type:
1416

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
2118

2219
This document highlights changes in type usage between ``mongosh`` and
2320
the legacy ``mongo`` shell. See the

source/reference/ejson/stringify.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -613,12 +613,12 @@ The output is:
613613
}
614614
]
615615

616+
.. _mongosh-ejson-stringify-legacy-output:
617+
616618
Legacy ``tojsononeline()``
617619
~~~~~~~~~~~~~~~~~~~~~~~~~~
618620

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
622622

623623
Run a sample query in ``mongosh`` and ``mongo`` to see the different
624624
formats.

source/reference/methods.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,7 @@ Native Methods
883883
script, respectively. The returned values are always absolute
884884
paths.
885885

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
888887

889888
* - .. _mongosh-native-method-print:
890889

source/reference/options.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,9 @@ Session Options
562562

563563
.. option:: --retryWrites
564564

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
569568

570569
For more information on sessions, see :ref:`sessions`.
571570

source/run-commands.txt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,10 @@ You can also terminate a script from within the script code by calling the
108108
``exit(<code>)`` command. For more information, refer to
109109
:ref:`Terminate a Script on Error <mongosh-terminate-script>`.
110110

111-
112111
Command Exceptions
113112
------------------
114113

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
125115

126116
Clear the ``mongosh`` Console
127117
-----------------------------

0 commit comments

Comments
 (0)