Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

working with multiple db in single query 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);

});
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript this inside arrow function 
Javascript :: javascript multiple startswith 
Javascript :: node js templates 
Javascript :: javascript test throw error 
Javascript :: throw new error( 
Javascript :: js object 
Javascript :: rxjs operators 
Javascript :: discord.js reply to message author 
Javascript :: stripe subscription node js 
Javascript :: dynamic key in javascript object 
Javascript :: convert json to dart 
Javascript :: array of objects in javascript 
Javascript :: json generator 
Javascript :: reactjs change favicon 
Javascript :: web app let user confirm closing tab 
Javascript :: list of javascript cheat sheet 
Javascript :: signup Using codegniter in ajax 
Javascript :: import css files maven resources with jsf 
Javascript :: next js find all the rerenders 
Javascript :: how to embed element in to array 
Javascript :: axios get request with nested params serialize qs 
Javascript :: storybook absolute paths 
Javascript :: example of a traditional NetSuite search 
Javascript :: dropzone not working when input is clicked 
Javascript :: create pair foreach item in array 
Javascript :: what is a 0 based language 
Javascript :: discord.js bot credits command 
Javascript :: npm run watch-poll 
Javascript :: jwtdecode has no call signatures angular 
Javascript :: edit jquery-connections 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =