|
|
@ -10,6 +10,7 @@ var _ = require('lodash');
|
|
|
|
var semver = require('semver');
|
|
|
|
var semver = require('semver');
|
|
|
|
var prompt = require('prompt');
|
|
|
|
var prompt = require('prompt');
|
|
|
|
var db;
|
|
|
|
var db;
|
|
|
|
|
|
|
|
var client;
|
|
|
|
|
|
|
|
|
|
|
|
var mongoModule = module.exports;
|
|
|
|
var mongoModule = module.exports;
|
|
|
|
|
|
|
|
|
|
|
@ -107,13 +108,13 @@ mongoModule.init = function (callback) {
|
|
|
|
|
|
|
|
|
|
|
|
connOptions = _.merge(connOptions, nconf.get('mongo:options') || {});
|
|
|
|
connOptions = _.merge(connOptions, nconf.get('mongo:options') || {});
|
|
|
|
|
|
|
|
|
|
|
|
mongoClient.connect(connString, connOptions, function (err, _db) {
|
|
|
|
mongoClient.connect(connString, connOptions, function (err, _client) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
winston.error('NodeBB could not connect to your Mongo database. Mongo returned the following error', err);
|
|
|
|
winston.error('NodeBB could not connect to your Mongo database. Mongo returned the following error', err);
|
|
|
|
return callback(err);
|
|
|
|
return callback(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
client = _client;
|
|
|
|
db = _db;
|
|
|
|
db = client.db();
|
|
|
|
|
|
|
|
|
|
|
|
mongoModule.client = db;
|
|
|
|
mongoModule.client = db;
|
|
|
|
|
|
|
|
|
|
|
@ -264,7 +265,7 @@ function getCollectionStats(db, callback) {
|
|
|
|
|
|
|
|
|
|
|
|
mongoModule.close = function (callback) {
|
|
|
|
mongoModule.close = function (callback) {
|
|
|
|
callback = callback || function () {};
|
|
|
|
callback = callback || function () {};
|
|
|
|
db.close(function (err) {
|
|
|
|
client.close(function (err) {
|
|
|
|
callback(err);
|
|
|
|
callback(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|