Last active
June 10, 2021 01:44
-
-
Save topogigiovanni/3f44170f1d2136b89b7655049ed7991e to your computer and use it in GitHub Desktop.
rodar query em todos databases mongos mongodb
This file contains hidden or 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
| // 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