Native Methods

Note

For details on specific methods, including syntax and examples,click on the specific method to go to its reference page.

NameDescription
cat()Returns the contents of the specified file.
cd()Changes the current working directory to the specified path.
copyDbpath()Copies a local dbPath. For internal use.
getHostName()Returns the hostname of the system running the mongo shell.
getMemInfo()Returns a document that reports the amount of memory used by the shell.
hostname()Returns the hostname of the system running the shell.
isInteractive()Returns a boolean indicating whether the mongo shell is running in interactive or script mode.
listFiles()Returns an array of documents that give the name and size of each object in the directory.
load()Loads and runs a JavaScript file in the shell.
ls()Returns a list of the files in the current directory.
md5sumFile()The md5 hash of the specified file.
mkdir()Creates a directory at the specified path.
pwd()Returns the current directory.
quit()Exits the current shell session.
removeFile()Removes the specified file from the local file system.
resetDbpath()Removes a local dbPath. For internal use.
sleep()Suspends the mongo shell for a given period of time.
setVerboseShell()Configures the mongo shell to report operation timing.
version()Returns the current version of the mongo shell instance.
_isWindows()Returns true if the shell runs on a Windows system; false if a Unix or Linux system.
_rand()Returns a random number between 0 and 1.