398609 (5) [Avatar] Offline
I am building a mongo client using nw.js and native nodejs mongodb driver .
I have managed to get all the databases in the server using listDatabases function, But I can't get collections for the databases. I know this is because I have mentioned 'test' at the time of connection.
Is there any way to get all the databases and all the collections like in robomongo or mongochef.?

My code :

var host = 'localhost';
var port = 27017;

function connectToMongoServer(host,port,cb) {
	dbHandle = new Db('test', new Server(host, port));
	// Establish connection to db
	dbHandle.open(function(err, db) {	

   	//Use the admin database for the operation
   	var adminDb = dbHandle.admin();
	  List all the available databases
	  adminDb.listDatabases(function(err, dbs) {
	    assert.equal(null, err);
	    assert.ok(dbs.databases.length > 0);


function populateDBWithCollections(db,cb) {
 		var result;
 			assert.ok(items.length > 0);
 			result = {name:'',collections:items};

But db.collections function doesn't exist . Is there any alternative way ?