fix: db info page

if there is no connection to db, connect first
This commit is contained in:
Barış Soner Uşaklı
2018-12-10 15:30:10 -05:00
parent a0f57c642c
commit 26ccd8f626
4 changed files with 40 additions and 21 deletions

View File

@@ -201,11 +201,18 @@ mongoModule.checkCompatibilityVersion = function (version, callback) {
};
mongoModule.info = function (db, callback) {
if (!db) {
return callback();
}
async.waterfall([
function (next) {
if (db) {
return setImmediate(next, null, db);
}
mongoModule.connect(nconf.get('mongo'), function (err, client) {
next(err, client ? client.db() : undefined);
});
},
function (db, next) {
mongoModule.client = mongoModule.client || db;
async.parallel({
serverStatus: function (next) {
db.command({ serverStatus: 1 }, next);