Dropping all collections in a MongoDB database

I needed to drop all the collections in a database without dropping the database.

The easiest way for would be to run the following javascript command.

var dbName = 'exampleDb';
db.getSiblingDB(dbName).getCollectionNames().forEach(function(collName) {
    if (!collName.startsWith("system.")) {
        print("Dropping ["+dbName+"."+collName+"]");
        db[collName].drop();
    }
})