Skip to content

Instantly share code, notes, and snippets.

View samsonayalew's full-sized avatar

Samson Ayalew samsonayalew

  • Addis Abeba, Ethiopia
View GitHub Profile
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();
var db = new Db('test', new Server('localhost', 27017));
// Establish connection to db
db.open(function(err, db) {
// Use the admin database for the operation
var adminDb = db.admin();
// List all the available databases
adminDb.listDatabases(function(err, dbs) {
assert.equal(null, err);