framez-server/Server/Utils/DBUtil.js

23 lines
479 B
JavaScript

// Config module
const Config = require('../Config/Config.js')
const mongoose = require('mongoose');
mongoose.connect(Config.mongoURL);
const Models = {}
var normalizedPath = require("path").join(__dirname, "..", "Schemas");
// Load All Schemas and put them in Shemas Obj
require("fs")
.readdirSync(normalizedPath)
.forEach((file) => {
Models[file.split('.')[0]] = require(normalizedPath + '/' + file);
});
const util = {
Models: Models
}
module.exports = util;