📅  最后修改于: 2022-03-11 15:03:24.443000             🧑  作者: Mango
// 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);
});