Skip to content

Commit 9354a17

Browse files
author
Dave
authored
DOCSP-19378 methods not available in mongosh (#437)
* DOCSP-19378 methods not available in mongosh * Staging updates * Internal review
1 parent eda5a42 commit 9354a17

23 files changed

+345
-81
lines changed

snooty.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ toc_landing_pages = [
118118
"/reference/method/js-database",
119119
"/reference/method/js-free-monitoring",
120120
"/reference/method/js-native",
121+
"/reference/method/js-native-legacy",
121122
"/reference/method/js-plan-cache",
122123
"/reference/method/js-replication",
123124
"/reference/method/js-role-management",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The native method listed here is for the legacy :binary:`mongo` shell.
2+
3+
To use native methods in :binary:`mongosh`, see
4+
:ref:`native-in-mongosh`.
5+

source/reference/method/cat.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ cat()
1010
:depth: 1
1111
:class: singlecol
1212

13+
.. note::
14+
15+
.. include:: /includes/fact-native-method-and-shell.rst
16+
1317
Definition
1418
----------
1519

@@ -19,26 +23,22 @@ Definition
1923
output relative to the current shell session and does not impact the
2024
server.
2125

26+
.. _cat-native-options:
27+
2228
.. list-table::
2329
:header-rows: 1
2430
:widths: 20 20 80
2531

2632
* - Parameter
27-
2833
- Type
29-
3034
- Description
3135

3236
* - ``filename``
33-
3437
- string
35-
3638
- The filepath to open. The filepath must be on the local file system.
3739

3840
* - ``useBinaryMode``
39-
4041
- boolean
41-
4242
- *Optional.* Flag to determine whether to open
4343
file in binary mode or text mode.
4444

source/reference/method/cd.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,29 @@ cd()
1010
:depth: 1
1111
:class: singlecol
1212

13+
.. note::
14+
15+
.. include:: /includes/fact-native-method-and-shell.rst
16+
1317
Definition
1418
----------
1519

1620
.. method:: cd(path)
1721

18-
1922
.. list-table::
2023
:header-rows: 1
2124
:widths: 20 20 80
2225

2326
* - Parameter
24-
2527
- Type
26-
2728
- Description
28-
29+
2930
* - ``path``
30-
3131
- string
32-
33-
- A path on the file system local to :binary:`~bin.mongosh` context.
32+
- A path on the file system local to the :binary:`mongo` shell
33+
context.
34+
3435

36+
:method:`cd()` changes the directory context of :binary:`mongo` and
37+
has no effect on the MongoDB server.
3538

36-
:method:`cd()` changes the directory context of
37-
:binary:`~bin.mongosh` and has no effect on the MongoDB server.

source/reference/method/getHostName.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ getHostName()
1010
:depth: 1
1111
:class: singlecol
1212

13+
.. note::
14+
15+
.. include:: /includes/fact-native-method-and-shell.rst
16+
1317
.. method:: getHostName()
1418

1519
:returns: The hostname of the system running :binary:`~bin.mongosh`.
20+

source/reference/method/getMemInfo.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ getMemInfo()
1010
:depth: 1
1111
:class: singlecol
1212

13+
.. note::
14+
15+
.. include:: /includes/fact-native-method-and-shell.rst
16+
1317
.. method:: getMemInfo()
1418

1519
Returns a document with two fields that report the amount of memory

source/reference/method/isInteractive.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ isInteractive()
1010
:depth: 1
1111
:class: singlecol
1212

13+
.. note::
14+
15+
.. include:: /includes/fact-native-method-and-shell.rst
16+
1317
.. method:: isInteractive()
1418

1519
.. versionadded:: 4.2
@@ -19,7 +23,6 @@ isInteractive()
1923
script mode:
2024

2125
- ``true`` if in interactive mode
22-
2326
- ``false`` if in script mode
2427

2528
Examples

source/reference/method/isWindows.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ _isWindows()
1010
:depth: 1
1111
:class: singlecol
1212

13+
.. note::
14+
15+
.. include:: /includes/fact-native-method-and-shell.rst
16+
1317
.. method:: _isWindows()
1418

1519
:returns: boolean.
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
.. _native-in-legacy:
2+
3+
==================================
4+
Native Methods in the Legacy 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+
The methods listed in this section are for the legacy :binary:`mongo`
16+
shell. To use native methods in :binary:`mongosh`, see
17+
:ref:`native-in-mongosh`.
18+
19+
The `mongocompat snippet
20+
<https://github.com/mongodb-labs/mongosh-snippets/blob/main/snippets/mongocompat/index.js>`__
21+
also provides access to legacy :binary:`mongo` shell APIs.
22+
23+
.. include:: /includes/extracts/methods-toc-explanation.rst
24+
25+
.. list-table::
26+
:widths: 30,70
27+
:header-rows: 1
28+
29+
* - Name
30+
- Description
31+
32+
* - :doc:`/reference/method/cat`
33+
34+
- Returns the contents of the specified file.
35+
36+
* - :doc:`/reference/method/cd`
37+
38+
- Changes the current working directory to the specified path.
39+
40+
* - :method:`copyDbpath()`
41+
42+
- Copies a local :setting:`~storage.dbPath`. For internal use.
43+
44+
* - :method:`getHostName()`
45+
46+
- Returns the hostname of the computer running the shell.
47+
48+
* - :method:`getMemInfo()`
49+
50+
- Returns a document that reports the amount of memory used by
51+
the shell.
52+
53+
* - :doc:`/reference/method/hostname`
54+
55+
- Returns the hostname of the system running the shell.
56+
57+
* - :doc:`/reference/method/isInteractive`
58+
59+
- Returns a boolean indicating whether the shell is running in
60+
interactive or script mode.
61+
62+
* - :method:`listFiles()`
63+
64+
- Returns an array of documents that show the name and size of
65+
each object in the directory.
66+
67+
* - :doc:`/reference/method/load`
68+
69+
- Loads and runs a JavaScript file in the shell.
70+
71+
* - :doc:`/reference/method/ls`
72+
73+
- Returns a list of the files in the current directory.
74+
75+
* - :method:`md5sumFile()`
76+
77+
- The :term:`md5` hash of the specified file.
78+
79+
* - :doc:`/reference/method/mkdir`
80+
81+
- Creates a directory in the specified path.
82+
83+
* - :doc:`/reference/method/pwd`
84+
85+
- Returns the current directory.
86+
87+
* - :doc:`/reference/method/quit`
88+
89+
- Exits the current shell session.
90+
91+
* - :method:`removeFile()`
92+
93+
- Removes the specified file from the local file system.
94+
95+
* - :method:`resetDbpath()`
96+
97+
- Removes a local :setting:`~storage.dbPath`. For internal use.
98+
99+
* - :doc:`/reference/method/sleep`
100+
101+
- Suspends :binary:`~bin.mongosh` for a period of time.
102+
103+
* - :method:`setVerboseShell()`
104+
105+
- Configures :binary:`~bin.mongosh` to report operation timing.
106+
107+
* - :doc:`/reference/method/version`
108+
109+
- Returns the current version of :binary:`~bin.mongosh` instance.
110+
111+
* - :method:`_isWindows()`
112+
113+
- Returns:
114+
115+
- ``true`` if the shell runs on Windows.
116+
- ``false`` if the shell runs on Unix or Linux.
117+
118+
* - :method:`_rand()`
119+
120+
- Returns a random number between ``0`` and ``1``.
121+
122+
123+
.. toctree::
124+
:titlesonly:
125+
:hidden:
126+
127+
/reference/method/cat
128+
/reference/method/cd
129+
/reference/method/copyDbpath
130+
/reference/method/getHostName
131+
/reference/method/getMemInfo
132+
/reference/method/hostname
133+
/reference/method/isInteractive
134+
/reference/method/listFiles
135+
/reference/method/load
136+
/reference/method/ls
137+
/reference/method/md5sumFile
138+
/reference/method/mkdir
139+
/reference/method/pwd
140+
/reference/method/quit
141+
/reference/method/removeFile
142+
/reference/method/resetDbpath
143+
/reference/method/sleep
144+
/reference/method/setVerboseShell
145+
/reference/method/version
146+
/reference/method/isWindows
147+
/reference/method/rand

0 commit comments

Comments
 (0)