Native Methods in mongosh
The methods listed in this section are mongosh
functional
replacements for the native methods that were available in the legacy
mongo
shell. These methods are not exact replacements: output
formats and some functionality may differ from the corresponding
legacy methods.
In addition to these methods, the mongocompat snippet
provides access to legacy mongo
shell APIs.
Note
In the following table <path>
and <filename>
are strings and
should be in quotes.
// process.chdir( <path> ) process.chdir( "./data/incoming" )
Legacy Method Name | Replacement | ||
---|---|---|---|
| Returns the contents of the specified file
The legacy
| ||
| Changes the current working directory to the specified path.
| ||
| Returns the hostname of the system running
| ||
| Returns a document that reports memory used by the shell.
| ||
| Returns the hostname of the computer running the shell.
| ||
| Returns a boolean indicating whether
| ||
| Returns an array of documents that give the name and type 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.
| ||
| Returns the md5 hash of the specified file.
| ||
| Creates a directory at the specified path.
| ||
| Returns the current directory.
| ||
| Exits the current shell session.
| ||
| Removes the specified file from the local file system.
| ||
| Sleep for the specified number of milliseconds.
| ||
| Returns the current version of
| ||
| Returns
| ||
| Returns a random number between
|