Readlebee/server/sequelize/models/index.js

23 lines
546 B
JavaScript
Raw Normal View History

const path = require('path');
module.exports = sequelize => {
const modelNames = [ // This is the order required to correctly get references.
'PermissionLevel',
'User',
'BookReference',
'Shelf',
'ShelfItem',
'Status',
'Review',
'Recommendation',
];
const models = {};
modelNames.forEach(modelName => {
const filename = `./${modelName}.js`;
models[modelName] = require(path.resolve(__dirname, filename))(sequelize);
});
return require(path.resolve(__dirname, '../associations'))(models);
};