Skip to content

Instantly share code, notes, and snippets.

@Orangetronic
Created May 30, 2019 13:10
Show Gist options
  • Save Orangetronic/237e303aee9d2df2ec51fefff9f769f7 to your computer and use it in GitHub Desktop.
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
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