ensl_gathers/db/index.js
Absurdon 79be2b8155 docker+upgrade
* Updated dependencies
  - React update needed transformation of React.createClass to ES2015
  classes
  - removed some deprecations/deprecated packages
  - added mulitple @types Dependencies to devDependencies for IDE code
  completion support
* added Docker related files
  - Dockerfile with build container
  - docker-compose.yml with mongodb and app
2020-10-11 19:49:26 +02:00

33 lines
1 KiB
JavaScript

"use strict";
var path = require("path");
var winston = require("winston");
var mongoose = require("mongoose");
var config = require(path.join(__dirname, "../config/config.js"));
var connect = function () {
mongoose.connect(config.mongo.uri, {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(
() => winston.info("MongoDB: Connection established"),
error => winston.error(error)
);
};
connect();
mongoose.connection.on("error", (error) => winston.error(error));
mongoose.connection.on("disconnected", () => winston.error("MongoDB: Was disconnected."));
mongoose.connection.on("reconnectFailed", () => winston.error("MongoDB: Reconnect Failed!"));
mongoose.connection.on("reconnected", () => winston.info("MongoDB: Connection established"));
// Load models
require(path.join(__dirname, "/models/event"));
require(path.join(__dirname, "/models/message"));
require(path.join(__dirname, "/models/session"));
require(path.join(__dirname, "/models/profile"));
require(path.join(__dirname, "/models/archivedGather"));
module.exports = mongoose;