Native Methods in the Legacy Shell
This version of the documentation is archived and no longer supported. View the current documentation to learn how to upgrade your version of MongoDB server.
The methods listed in this section are for the legacy mongo
shell. To use native methods in mongosh
, see
Native Methods in mongosh
.
The mongocompat snippet
also provides access to legacy mongo
shell APIs.
Note
For details on specific methods, including syntax and examples, click on the specific method to go to its reference page.
Name | Description |
---|---|
Returns the contents of the specified file. | |
Changes the current working directory to the specified path. | |
Copies a local dbPath . For internal use. | |
Returns the hostname of the computer running the shell. | |
Returns a document that reports the amount of memory used by
the shell. | |
Returns the hostname of the system running the shell. | |
Returns a boolean indicating whether the shell is running in
interactive or script mode. | |
Returns an array of documents that show the name and size of
each object in the directory. | |
Loads and runs a JavaScript file in the shell. | |
Returns a list of the files in the current directory. | |
The md5 hash of the specified file. | |
Creates a directory in the specified path. | |
Returns the current directory. | |
Exits the current shell session. | |
Removes the specified file from the local file system. | |
Removes a local dbPath . For internal use. | |
Suspends mongosh for a period of time. | |
Configures mongosh to report operation timing. | |
Returns the current version of mongosh instance. | |
Returns:
| |
Returns a random number between 0 and 1 . |