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