Skip to content

Instantly share code, notes, and snippets.

@topogigiovanni
Last active June 10, 2021 01:44
Show Gist options
  • Select an option

  • Save topogigiovanni/3f44170f1d2136b89b7655049ed7991e to your computer and use it in GitHub Desktop.

Select an option

Save topogigiovanni/3f44170f1d2136b89b7655049ed7991e to your computer and use it in GitHub Desktop.
rodar query em todos databases mongos mongodb
// Switch to admin database and get list of databases.
db = db.getSiblingDB("admin");
dbs = db.runCommand({ "listDatabases": 1 }).databases;
// Iterate through each database.
dbs.forEach(function(database) {
db = db.getSiblingDB(database.name);
// Get the Group collection
collection = db.getCollection("Group");
// Iterate through all documents in collection.
/*
collection.find().forEach(function(doc) {
// Print the meldingId field.
print(doc.meldingId);
});
*/
var meldingIds = collection.distinct('meldingId');
print(meldingIds);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment