How does Mongodb bulk delete databases with specified criteria?

  mongodb, question

For example, I have 1,000 databases, and I want to delete all the databases that begin with a, how do I do it?
(Note that database is not collection)

It takes a little skill, but it’s not too much trouble. A script is done:

db.runCommand({listDatabases: 1}).databases.forEach(function(database) {
 if(^a/)) {

Probably throughlistDatabaseGet all the libraries, then find the libraries that meet your criteria, and thendropDatabase()Delete it.
Pay attention to avoid key system libraries, such aslocal,config,adminWait