MONGO Shell startup configuration file. Mongorc.js (ii)
If you have a. mongorc.js file under your home directory, he will run automatically when you start the shell. Use it to initialize any helper methods you use frequently and delete methods that you do not want to accidentally manipulate.
For example, you do not want to use the default Dropdatabase () method, and you can add the following command to the. mongorc.js file:
DB.prototype.dropDatabase = function () {print ("No dropping dbs!"); } db.dropdatabase = DB.prototype.dropDatabase;
The above example changes the Dropdatabase () helper method so that he prints only one line of information without actually deleting the database.
Note that this technique is not a security measure, and the stubborn user can still delete the database without using the helper. However, removing the dangerous admin Privilege command can also help prevent the "collapse of the Levee."
Several recommendations are removed when using the helper command in. Mongorc.js:
DB.prototype.shutdownServer
DBCollection.prototype.drop
DBCollection.prototype.ensureIndex
DBCollection.prototype.reIndex
DBCollection.prototype.dropIndexes
This article is from the SQL Server deep dives blog, so be sure to keep this source http://ultrasql.blog.51cto.com/9591438/1707353
MONGO Shell startup configuration file. Mongorc.js (ii)