For models/index.js I found the line const model = sequelize['import'](path.join(__dirname, file));
to instead need to be something like: const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
It kept complaining sequelize['import'] was not a function.
Also, not sure when the version might have changed but they suggest "require" over "import". sequelize.org/master/manual/models...
The documentation suggests the sequelize['import'] style should work (even w/ "require") but it wasn't working for me.
I'll echo Carles and others, this article has been an absolute gem! It has saved me days of scouring for insights on how to hook up Sequelize.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
For models/index.js I found the line
const model = sequelize['import'](path.join(__dirname, file));
to instead need to be something like:
const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
It kept complaining
sequelize['import'] was not a function
.Also, not sure when the version might have changed but they suggest "require" over "import". sequelize.org/master/manual/models...
The documentation suggests the
sequelize['import']
style should work (even w/ "require") but it wasn't working for me.I'll echo Carles and others, this article has been an absolute gem! It has saved me days of scouring for insights on how to hook up Sequelize.