From dfc8aacbaed46981bf6a6b8fe289798d2f1602ee Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Sun, 5 Jan 2014 19:08:36 -0500 Subject: [PATCH] closes #735, removed create collection calls --- app.js | 2 +- src/database/mongo.js | 39 +++++++++++---------------------------- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/app.js b/app.js index 9bc487bc4f..d673bcbccf 100644 --- a/app.js +++ b/app.js @@ -74,7 +74,7 @@ nconf.set('upload_url', path.join(path.sep, nconf.get('relative_path'), 'uploads', path.sep)); nconf.set('base_dir', __dirname); - winston.info('Initializing NodeBB v' + pkg.version + ', on port ' + nconf.get('port') + ', using Redis store at ' + nconf.get('redis:host') + ':' + nconf.get('redis:port') + '.'); + winston.info('Initializing NodeBB v' + pkg.version + ', on port ' + nconf.get('port') + ', using ' + nconf.get('database') +' store at ' + nconf.get(nconf.get('database') + ':host') + ':' + nconf.get(nconf.get('database') + ':port') + '.'); winston.info('NodeBB instance bound to: ' + ((nconf.get('bind_address') === "0.0.0.0" || !nconf.get('bind_address')) ? 'Any address (0.0.0.0)' : nconf.get('bind_address'))); if (process.env.NODE_ENV === 'development') { diff --git a/src/database/mongo.js b/src/database/mongo.js index b0c028a823..fd07ad7f2a 100644 --- a/src/database/mongo.js +++ b/src/database/mongo.js @@ -41,45 +41,28 @@ winston.error(err.message); process.exit(); } - createCollections(); + createIndices(); }); } else { - createCollections(); + createIndices(); } - function createCollections() { - db.createCollection('objects', {w:1}, function(err, collection) { + function createIndices() { + db.collection('objects').ensureIndex({_key :1}, {background:true}, function(err) { if(err) { - winston.error('Error creating collection (objects) ' + err.message); - return; + winston.error('Error creating index ' + err.message); } + }); - if(collection) { - collection.ensureIndex({_key :1}, {background:true}, function(err, name) { - if(err) { - winston.error('Error creating index ' + err.message); - } - }); - - collection.ensureIndex({'expireAt':1}, {expireAfterSeconds:0, background:true}, function(err, name) { - if(err) { - winston.error('Error creating index ' + err.message); - } - }); + db.collection('objects').ensureIndex({'expireAt':1}, {expireAfterSeconds:0, background:true}, function(err) { + if(err) { + winston.error('Error creating index ' + err.message); } }); - db.createCollection('search', {w:1}, function(err, collection) { + db.collection('search').ensureIndex({content:'text'}, {background:true}, function(err) { if(err) { - winston.error('Error creating collection (search) ' + err.message); - return; - } - if(collection) { - collection.ensureIndex({content:'text'}, {background:true}, function(err, name){ - if(err) { - winston.error('Error creating index ' + err.message); - } - }); + winston.error('Error creating index ' + err.message); } });