|
|
|
@ -13,13 +13,13 @@
|
|
|
|
|
|
|
|
|
|
module.init = function(callback) {
|
|
|
|
|
mongoClient.connect('mongodb://'+ mongoHost + ':' + nconf.get('mongo:port') + '/' + nconf.get('mongo:database'), function(err, _db) {
|
|
|
|
|
db = _db;
|
|
|
|
|
|
|
|
|
|
if(err) {
|
|
|
|
|
winston.error("NodeBB could not connect to your Mongo database. Mongo returned the following error: " + err.message);
|
|
|
|
|
process.exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
db = _db;
|
|
|
|
|
|
|
|
|
|
module.client = db;
|
|
|
|
|
|
|
|
|
|
module.sessionStore = new mongoStore({
|
|
|
|
@ -27,17 +27,19 @@
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO : what is the db user name??
|
|
|
|
|
if(nconf.get('mongo:password') && nconf.get('mongo:username')) {
|
|
|
|
|
db.authenticate(nconf.get('mongo:username'), nconf.get('mongo:password'), function (err) {
|
|
|
|
|
if(err) {
|
|
|
|
|
winston.error(err.message);
|
|
|
|
|
}
|
|
|
|
|
process.exit();
|
|
|
|
|
}
|
|
|
|
|
createCollections();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
createCollections();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createCollections() {
|
|
|
|
|
db.createCollection('objects', function(err, collection) {
|
|
|
|
|
if(err) {
|
|
|
|
|
winston.error("Error creating collection " + err.message);
|
|
|
|
@ -66,7 +68,8 @@
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
callback(err);
|
|
|
|
|
callback(null);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|