ensl_gathers/db/index.mjs

31 lines
913 B
JavaScript
Raw Permalink Normal View History

import winston from "winston"
import mongoose from "mongoose";
import config from "../config/config.mjs";
2015-08-05 00:41:43 +00:00
2023-03-05 13:07:36 +00:00
mongoose.set('strictQuery', true);
2015-10-01 10:21:59 +00:00
var connect = function () {
mongoose.connect(config.mongo.uri, {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(
() => winston.info("MongoDB: Connection established"),
error => winston.error(error)
);
2015-10-01 10:21:59 +00:00
};
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!"));
2015-10-01 10:21:59 +00:00
mongoose.connection.on("reconnected", () => winston.info("MongoDB: Connection established"));
2015-08-05 00:41:43 +00:00
// Load Models
import "./models/event.mjs";
import "./models/message.mjs";
import "./models/session.mjs";
import "./models/profile.mjs";
import "./models/archivedGather.mjs";