2015-08-05 00:41:43 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var path = require("path");
|
2015-10-01 12:56:51 +00:00
|
|
|
var winston = require("winston");
|
2015-08-05 00:41:43 +00:00
|
|
|
var mongoose = require("mongoose");
|
|
|
|
var config = require(path.join(__dirname, "../config/config.js"));
|
|
|
|
|
2015-10-01 10:21:59 +00:00
|
|
|
var connect = function () {
|
|
|
|
mongoose.connect(config.mongo.uri, {
|
|
|
|
server: {
|
|
|
|
socketOptions: {
|
|
|
|
keepAlive: 1,
|
|
|
|
connectTimeoutMS: 30000
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
connect();
|
|
|
|
|
|
|
|
mongoose.connection.on("error", function (error) {
|
|
|
|
winston.error(error);
|
|
|
|
});
|
|
|
|
|
|
|
|
mongoose.connection.on("disconnected", function () {
|
|
|
|
winston.error("MongoDB: Was disconnected.");
|
|
|
|
});
|
2015-08-05 00:41:43 +00:00
|
|
|
|
|
|
|
// Load models
|
2015-12-29 16:26:03 +00:00
|
|
|
require(path.join(__dirname, "/models/event"));
|
2015-08-05 00:41:43 +00:00
|
|
|
require(path.join(__dirname, "/models/message"));
|
2015-08-18 09:56:35 +00:00
|
|
|
require(path.join(__dirname, "/models/session"));
|
2015-08-27 18:42:45 +00:00
|
|
|
require(path.join(__dirname, "/models/profile"));
|
2015-09-21 21:59:00 +00:00
|
|
|
require(path.join(__dirname, "/models/archivedGather"));
|
2015-08-05 00:41:43 +00:00
|
|
|
|
2015-10-01 10:21:59 +00:00
|
|
|
module.exports = mongoose;
|