Created
May 30, 2019 13:10
-
-
Save Orangetronic/237e303aee9d2df2ec51fefff9f769f7 to your computer and use it in GitHub Desktop.
run a command across all the databases in mongo from the Studio 3T mongo shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db = db.getSiblingDB("admin"); | |
dbs = db.runCommand({ "listDatabases": 1 }).databases; | |
// Iterate through each database and get its collections. | |
dbs.forEach(function(database) { | |
db = db.getSiblingDB(database.name); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment