.
This commit is contained in:
parent
94cfa548ce
commit
2c942b7a50
@ -14,6 +14,7 @@ const globOptions = {
|
||||
}
|
||||
|
||||
log.info('Configurando DB.');
|
||||
const db = {};
|
||||
|
||||
const sequelize = new Sequelize(
|
||||
config.database.database,
|
||||
@ -26,21 +27,24 @@ const sequelize = new Sequelize(
|
||||
}
|
||||
);
|
||||
|
||||
const db = {};
|
||||
db.sequelize = sequelize;
|
||||
db.Sequelize = Sequelize;
|
||||
try {
|
||||
db.sequelize = sequelize;
|
||||
db.Sequelize = Sequelize;
|
||||
|
||||
glob.sync("**/*.model.js", globOptions)
|
||||
.forEach(function (file) {
|
||||
var model = sequelize.import(file);
|
||||
log.info('Loading "' + model.name + '" model.');
|
||||
db[model.name] = model;
|
||||
glob.sync("**/*.model.js", globOptions)
|
||||
.forEach(function (file) {
|
||||
var model = sequelize.import(file);
|
||||
log.info('Loading "' + model.name + '" model.');
|
||||
db[model.name] = model;
|
||||
});
|
||||
|
||||
Object.keys(db).forEach(function (modelName) {
|
||||
if (db[modelName].associate) {
|
||||
db[modelName].associate(db);
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(db).forEach(function (modelName) {
|
||||
if (db[modelName].associate) {
|
||||
db[modelName].associate(db);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
module.exports = db;
|
||||
Loading…
Reference in New Issue
Block a user