Store a function to delete all db in MongoDb
Deleting everything in a test MongoDb is a common operation for test and dev machine and it is a relative simple operation that I described here. After a little while I got really tired every time to search my gist or into my hd the little script that deletes everything , thus I decided to store it inside the admin db.
The solution is really really simple, just connect to the admin database and register a server side function to delete all databases.
|
|
Once the function is saved, you should see it from a GUI tool like Robo 3T.
Figure 1: DeleteAllDb function stored inside the admin database.
Now you can simply load all functions from the Shell and execute the new DeleteAllDbFunction.
|
|
And now you can avoid looking around from the script, just invoke DeleteAllDb(db) function from the shell and you will delete all db, except Admin and Local.
Gian Maria.