Please make an upgrade to the latest version of sequelize ( > 6.x)
musmanfaisal opened this issue · 1 comments
musmanfaisal commented
I have been struggling to make this thing work for past 2 days. It would be really helpful if you could help me with this. I am able to run it with v5.21.11 of sequelize. But above 6.x, sequelize.import is removed and dynamic import fails in the models index.js file. I have mentioned in the file which block fails to execute with 6.x
billygl commented
for now, this code helps to dynamically import the models:
const files = require.context('./', false, /\.js$/i);
files.keys().forEach(key => {
if(key.includes('index')){
return
}
const model = files(key)(sequelize, Sequelize.DataTypes)
db[model.name] = model;
});