Skip to content

Commit 064ae6c

Browse files
authored
DOCSP-25400 Resolve mongosh build errors for native methods (#238)
* DOCSP-25400 Resolve mongosh build errors for native methods * internal review feedback
1 parent e3aeea0 commit 064ae6c

File tree

5 files changed

+46
-19
lines changed

5 files changed

+46
-19
lines changed

source/changelog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ v0.9.0
675675

676676
New features in this release:
677677

678-
- Support for the :method:`load()` method.
678+
- Support for the :ref:`load() <mongosh-native-method-load>` method.
679679

680680
- Support for AWS IAM authentication.
681681

source/reference/methods.txt

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -827,12 +827,22 @@ Native Methods
827827

828828
- Description
829829

830-
* - ``isInteractive()``
830+
* - .. _mongosh-native-method-cd:
831+
832+
``cd()``
833+
834+
- Changes the current working directory to the specified path.
835+
836+
* - .. _mongosh-native-method-isInteractive:
837+
838+
``isInteractive()``
831839

832840
- Returns a boolean indicating whether mongosh is running in
833841
interactive or script mode.
834842

835-
* - :manual:`load() </reference/method/load/>`
843+
* - .. _mongosh-native-method-load:
844+
845+
``load()``
836846

837847
- Loads and runs a JavaScript file in the shell.
838848

@@ -845,7 +855,9 @@ Native Methods
845855
In the legacy shell, you cannot not access the script's file name
846856
or directory using the ``load()`` method.
847857

848-
* - ``print()``
858+
* - .. _mongosh-native-method-print:
859+
860+
``print()``
849861

850862
- Print the specified text or variable. ``print()`` and ``printjson()``
851863
are aliases for ``console.log()``.
@@ -859,15 +871,28 @@ Native Methods
859871
> print(x)
860872
example text
861873

862-
* - ``quit()``
874+
* - .. _mongosh-native-method-pwd:
875+
876+
``pwd()``
877+
878+
- Returns the current working directory of the active shell session.
863879

880+
* - .. _mongosh-native-method-quit:
881+
882+
``quit()``
883+
864884
- Exits the current shell session.
865885

866-
* - ``sleep()``
867-
886+
* - .. _mongosh-native-method-sleep:
887+
888+
``sleep()``
889+
868890
- Suspends the |mongo| shell for a given period of time.
869891

870-
* - ``version()``
892+
893+
* - .. _mongosh-native-method-version:
894+
895+
``version()``
871896

872897
- Returns the current version of the ``mongosh`` instance.
873898

source/reference/options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Connection Options
134134
the hostname does not match the ``SAN`` (or ``CN``), the
135135
|mdb-shell| shell fails to connect.
136136

137-
.. _example-connect-mongosh-using-srv:
137+
.. _example-connect-mongosh-using-srv:
138138

139139
For :manual:`DNS seedlist connections </reference/connection-string/#dns-seedlist-connection-format/>`,
140140
Specify the connection protocol as ``mongodb+srv``, followed by

source/write-scripts.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ Execute a Script from Within mongosh
2929
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3030

3131
You can execute a ``.js`` file from within the |mdb-shell|
32-
using the :method:`load()` method.
32+
using the :ref:`load() <mongosh-native-method-load>` method.
3333

3434
File Paths
3535
``````````
3636

37-
The :method:`load()` method accepts relative and absolute paths. If the
38-
current working directory of the |mdb-shell| is ``/data/db``, and
39-
``connect-and-insert.js`` is in the ``/data/db/scripts`` directory, then
40-
the following calls within the |mdb-shell| are equivalent:
37+
The :ref:`load() <mongosh-native-method-load>` method accepts relative
38+
and absolute paths. If the current working directory of the |mdb-shell|
39+
is ``/data/db``, and ``connect-and-insert.js`` is in the
40+
``/data/db/scripts`` directory, then the following calls within the
41+
|mdb-shell| are equivalent:
4142

4243
.. code-block:: javascript
4344
:copyable: false
@@ -98,7 +99,8 @@ The following example creates and executes a script that:
9899

99100
.. note::
100101

101-
There is no search path for the :method:`load()` method. If the target
102+
There is no search path for the :ref:`load()
103+
<mongosh-native-method-load>` method. If the target
102104
script is not in the current working directory or the full specified
103105
path, the |mdb-shell| cannot access the file.
104106

source/write-scripts/require-load-differences.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ You can use the following types of scripts with ``mongosh``:
2525

2626
- Code entered directly into the REPL.
2727
- The :ref:`mongoshrc.js <mongoshrc-js>` file.
28-
- Code loaded with the :method:`load()` method.
28+
- Code loaded with the :ref:`load() <mongosh-native-method-load>` method.
2929

3030
- Node.js scripts, which are any scripts loaded with ``require()``,
3131
including npm packages. These scripts are always files.
@@ -68,10 +68,10 @@ The type of script determines how you specify file paths with
6868
.. tip::
6969

7070
To return the current working directory of the shell, run the
71-
:method:`pwd()` method from your script.
71+
:ref:`pwd() <mongosh-native-method-pwd>` method from your script.
7272

73-
To change the shell's working directory, use the :method:`cd()`
74-
method in your script.
73+
To change the shell's working directory, use the :ref:`cd()
74+
<mongosh-native-method-cd>` method in your script.
7575

7676
Load External Code in a ``mongosh`` Script
7777
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)