When booting, MONGO checks a JavaScript file in the user's home directory. Mongorc.js. If found, MONGO resolves the. Mongorc.js content before displaying the message for the first time.
If you use the shell to execute a JavaScript file or evaluate an expression, either by using the--eval option at the command line or by specifying a. js file to Mongo,mongo will read the. mongorc.js file after completing the processing of the JavaScript.
You can use the--NORC option to prevent loading. Mongorc.js.
customizing Shell Tips
Create a MONGO command-line prompt in the form of <database>@
Host = Db.serverstatus (). host;
prompt = function () {
return db+ "@" +host+ ">";
}
Prohibit deletion of databases
DB.prototype.dropDatabase = function () {
Print ("Prohibit deletion of databases.");
}
Prohibit deleting collections
DBCollection.prototype.drop = function () {
Print ("Prohibit delete collection.");
}
Prohibit deletion of indexes
DBCollection.prototype.dropIndex = function () {
Print ("Prohibit deletion of indexes.");
Mongorc.js file