1// Switch to admin database and get list of databases.
2db = db.getSiblingDB("admin");
3dbs = db.runCommand({ "listDatabases": 1 }).databases;
4
5// Iterate through each database.
6dbs.forEach(function(database) {
7 db = db.getSiblingDB(database.name);
8
9 // Get the Group collection
10 collection = db.getCollection("Group");
11
12 // Iterate through all documents in collection.
13 /*
14 collection.find().forEach(function(doc) {
15
16 // Print the meldingId field.
17 print(doc.meldingId);
18 });
19 */
20
21 var meldingIds = collection.distinct('meldingId');
22 print(meldingIds);
23
24});
25