Listing all collections in a mongo database within a nodejs script

In the 2.0 version of the MongoDB driver for node.js you can use listCollections to get a cursor that contains the information of all collections. You can then call toArray on the cursor to retrieve the info.

db.listCollections().toArray(function(err, collInfos) {
    // collInfos is an array of collection info objects that look like:
    // { name: 'test', options: {} }
});

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)