Skip to content

Instantly share code, notes, and snippets.

@samsonayalew
Created May 30, 2015 05:22
Show Gist options
  • Save samsonayalew/f7adaf21145bb9f78a5e to your computer and use it in GitHub Desktop.
Save samsonayalew/f7adaf21145bb9f78a5e to your computer and use it in GitHub Desktop.
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);
assert.ok(dbs.databases.length > 0);
db.close();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment