Monday, July 03, 2017

Store a Function to Delete All Databases in MongoDB [Code Snippet]

DZone Database Zone
Store a Function to Delete All Databases in MongoDB [Code Snippet]

Deleting everything in a test MongoDB is a common operation for test and dev machines. It's a relatively simple operation that I have described here. After a little while, I got really tired of searching for the little script that deletes everything every time I needed it. Thus, I decided to store it inside the admin database.

The solution is really simple. Just connect to the admin database and register a server-side function to delete all databases.

No comments:

Fun With SQL: Functions in Postgres

DZone Database Zone Fun With SQL: Functions in Postgres In our previous  Fun with SQL  post on the  Citus Data  blog, we covered w...