Sequelize > 6.0 Require and Import in ES6

Viewed 89

I am using Sequelize 6, and the default way Sequelize generates the importing of the modules is:

const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes)

The issue is that because I am using ES6 (I defined in package.json as type=module) I cannot use require as it is not defined. The other way of importing the models is with:

sequelize['import']

But this function has been deprecated in Sequelize 6.0.

What's the way of loading all the models in ES6?

Thanks

0 Answers
Related