Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
musmanfaisal opened this issue Jun 6, 2021 · 1 comment

Comments

@musmanfaisal
Copy link

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

@billygl
Copy link

billygl commented Feb 16, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants