nextjs-sequelize icon indicating copy to clipboard operation
nextjs-sequelize copied to clipboard

Please make an upgrade to the latest version of sequelize ( > 6.x)

Open musmanfaisal opened this issue 4 years ago • 1 comments

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

Thanks in advance Screen Shot 2021-06-06 at 8 07 00 PM

musmanfaisal avatar Jun 06 '21 15:06 musmanfaisal

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;
});

billygl avatar Feb 16 '22 23:02 billygl