This commit is contained in:
Baris Usakli
2013-12-09 14:16:04 -05:00
parent 27ac24b1e3
commit 0000a7f0b9
3 changed files with 33 additions and 17 deletions

View File

@@ -2,17 +2,25 @@
(function(module) {
'use strict';
var mongoClient = require('mongodb').MongoClient,
winston = require('winston'),
var winston = require('winston'),
async = require('async'),
nconf = require('nconf'),
express = require('express'),
mongoStore = require('connect-mongo')(express),
mongoHost = nconf.get('mongo:host'),
db;
db,
mongoClient,
mongoStore;
try {
mongoClient = require('mongodb').MongoClient;
mongoStore = require('connect-mongo')(express);
} catch (err) {
winston.error('Unable to initialize mongo! ' + err.message);
process.exit();
}
module.init = function(callback) {
mongoClient.connect('mongodb://'+ mongoHost + ':' + nconf.get('mongo:port') + '/' + nconf.get('mongo:database'), function(err, _db) {
mongoClient.connect('mongodb://'+ nconf.get('mongo:host') + ':' + nconf.get('mongo:port') + '/' + nconf.get('mongo:database'), function(err, _db) {
if(err) {
winston.error("NodeBB could not connect to your Mongo database. Mongo returned the following error: " + err.message);
process.exit();