Sample Header Ad - 728x90

Mongo Preventing access to dangerous command

1 vote
1 answer
55 views
Reading Mongo: Definite guide : In first chapter, author mentions the following snippet to change some of the default commands of db:
var no = function() {
   print("Not on my watch.");
};

// Prevent dropping databases
db.dropDatabase = DB.prototype.dropDatabase = no;

// Prevent dropping collections
DBCollection.prototype.drop = no;

// Prevent dropping an index
DBCollection.prototype.dropIndex = no;

// Prevent dropping indexes
DBCollection.prototype.dropIndexes = no;
I know db is pointing to current database, but my question is from where does DB is coming from?
Asked by Cody (123 rep)
Mar 30, 2024, 01:03 PM
Last activity: Apr 1, 2024, 02:49 AM