mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
cleanup mongo init
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -309,7 +309,6 @@ Upgrade.upgradeMongo = function(callback) {
|
||||
async.series([
|
||||
function(next) {
|
||||
db.get('schemaDate', function(err, value) {
|
||||
console.log(schemaDate)
|
||||
schemaDate = value;
|
||||
thisSchemaDate = new Date(2013, 11, 6).getTime();
|
||||
next();
|
||||
|
||||
Reference in New Issue
Block a user