DEV Community

Discussion on: Getting Started with Sequelize and Postgres

Collapse
 
obsidianstorms profile image
Rick • Edited

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.