.mongorc.js
The .mongorc.js
file is used if you want to have some JavaScript loaded every time you start the mongo
shell:
On Linux, Unix, and OS X
mongo
looks for this file in$HOME/.mongorc.js
.On Windows,
mongo.exe
looks for this file in%HOME%.mongorc.js
or%HOMEDRIVE%%HOMEPATH%.mongorc.js
.
Typically you only want to store re-usable functions in your .mongorc.js
.
Other ways to load JavaScript into a mongo
shell session include:
using the
load()
command in amongo
shell:load("/path/to/something.js")
.passing a JavaScript filename as a command line parameter when starting the
mongo
shell:mongo /path/to/something.js
pasting JavaScript directly into the
mongo
shell (e.g. copy & paste from a tutorial)