showing results for - "working with multiple db in single query mongodb"
Sarah
29 Apr 2016
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
queries leading to this page
mongodb query multiple tablesquery multiple objects mongodbsame query on multiple mongodb collectionsmongo read from multiple databases in same queryhow to query multiple mongo db collections at once nodequery multiple tables mongodbmongodb use 2 queriesquery multiple documents in mongodbmongodb query multiple documentsmongodb multiple query how to write a query in mongo db for multiple matchesrun multiple queries in mongodbmongodb execute multiple querymultiple queries in mongodbmongodb multiple collections queriesmultiple query in mongo nodemongodb multi queryhow to query over a multiple collections in mongodbmongodb find multiple queriesquery multiple collections mongodbquery multiple collections in mongodbhow to query multiple collections in mongodbhow to have more than one query in mongodbmongodb query multiple collections matchhow to run multiple queries in mongodbcreate multiple query for mongodbmultiple dbs mongodbmongodb multiple level querycombine multiple queries mongo dbhow to search for multiple query in mongodb using 24ormultiple multi level collections query in mongodbhow to query multiple mongodb databaseworking with multiple db in single query mongodbhow to query with multiple fields in mongodbquery multiple databases knecan you query multiple collections in mongodvmongo find multiple querymultiple in mongodbhow to use multiple select in mongodbmongodb multiple db in single connectionmongodb query from multiple collectionsrunning multiple mongodb queries on multiple fieldsmongodb query multiple databasesmultiple dbs in mongodbmongodb select data with multiple object imongodb multiple querieshow to make multiple query fields in mongodbmongodb query multiple collectionsusing multiple 24alls together in mongodbhow to make multiple query fielda in mongodbmongodb multiple queries at onceget multiple entry from mongodb in sinle query with different different valuemultiple mongodb databasesmultiple query in mongoengine 24multiple mongodbmongodb query across multiple databasesmultiple query mongodbmongodb run multiple queriesfind data with multiple query in mongodbexecute multiple queries in mongodbmongo query multiple collectionsmongodb multiple databaseadd multiple queriess to find in mongo dbhow to make multiple query field in mongodbconnect to multiple mongo databases at onceworking with multiple db in single query mongodb