Answers for "db.user.count({updated on: {$not: {$type: 9}}}).foreach(function(doc) { doc.updated on = new date(doc.updatedon); db.user.save(doc); })"

2

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);
    });
});
Posted by: Guest on April-30-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language