The function getDBs() function returns all the database list
db.getMongo().getDBs()
The runCommand is a special type of query called a database command and its is used database administration. The listDatabases parameter provides a list of all existing databases.
You can see all commands by running the db.listCommands()
command.
db.runCommand({ “listDatabases”: 1 }).databases;