Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

foreach db mongodb

// Switch to admin database and get list of databases.
db = db.getSiblingDB("admin");
dbs = db.runCommand({ "listDatabases": 1 }).databases;
// Iterate through each database and get its collections.
dbs.forEach(function(database) {
    db = db.getSiblingDB(database.name);
    cols = db.getCollectionNames();
    // Iterate through each collection.
    cols.forEach(function(col) {
        // Do something with each collection.
        print(col);
    });
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: first repeated character in a string javascript 
Javascript :: How to get the Class Name of an Object in JavaScript 
Javascript :: get an array with unique values 
Javascript :: model validation 
Javascript :: jquery hover event 
Javascript :: what is computed in mobx 
Javascript :: math.floor js 
Javascript :: Terminating timed out worker 
Javascript :: replace all js 
Javascript :: js copy to clipboard 
Javascript :: modal show with jquery ready function 
Javascript :: javascript auto hide navbar 
Javascript :: react native linear gradient 
Javascript :: how to get a toggle button to do different js functions 
Javascript :: how to remove an object from array in react native 
Javascript :: how to manage a db connection in javascript 
Javascript :: write json file c# 
Javascript :: reactjs get url query params as object 
Javascript :: javascript declare a variable 
Javascript :: javascript log to console 
Javascript :: date range filter 
Javascript :: mathjax new line 
Javascript :: react hook form reset 
Javascript :: set cookie and get cookie in javascript 
Javascript :: javascript storage get set item 
Javascript :: jquery .click function call 
Javascript :: javascript toisostring without milliseconds 
Javascript :: react-router-dom useLocation 
Javascript :: how to get checked value of checkbox in jquery 
Javascript :: Update multiple documents by id set. Mongoose 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =