Skip to content

Instantly share code, notes, and snippets.

@lenivene
Created June 28, 2023 18:01
Show Gist options
  • Save lenivene/d872d2b15bde08bffbdfe35e7e9cd31c to your computer and use it in GitHub Desktop.
Save lenivene/d872d2b15bde08bffbdfe35e7e9cd31c to your computer and use it in GitHub Desktop.
Drop all database in mongo using Robo 3T
const dbRequired = ["admin", "config", "local"];
db.getMongo()
.getDBNames()
.forEach(function (name) {
if (!dbRequired.includes(name)) {
db.getSiblingDB(name).dropDatabase();
print("Dropped database: " + name);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment