Skip to content

Instantly share code, notes, and snippets.

@samsonayalew
Created May 30, 2015 07:19
Show Gist options
  • Save samsonayalew/d20b17f82a2b45161100 to your computer and use it in GitHub Desktop.
Save samsonayalew/d20b17f82a2b45161100 to your computer and use it in GitHub Desktop.
var db = new Db('local', new Server('localhost', 27017));
module.exports.dbs = exports.dbs;
exports.dbs = function(callback){
db.open(function(err, db){
if(err) callback(err);
var adminDb = db.admin();
adminDb.listDatabases(function(err, dbs){
if(err) callback(err);
db.close();
callback(null, dbs);
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment