This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |