I've been stuck trying to get Sequelize to work normally for a week now. At first, everything works properly: migrations etc, until I try to connect the models to my routes in express; that's when everything breaks and I get this annoying error
throw new Error('Dialect needs to be explicitly supplied as of v4.0.0')
I'm using Postgres as my DB and I've supplied postgres as the dialect, so I don't understand what next needs to be done!
I've read through this GitHub gist multiple times, but can see nothing wrong with my interaction with this library; any help, please?
Has anyone experienced this? Is there something I'm doing wrong? I'd appreciate pointers to anything helpful.
Emmanuel
I was finally able to get it working. Most of the solutions I found online were like this:
"development": { "use_env_variable": "DATABASE_URL", "dialect": "postgres" }, "production": { "use_env_variable": "DATABASE_URL", "dialect": "postgres" } }They're mostly using config.json files. I used a config.js file instead and wrote the dialect option as an object like this instead
dialect: { dialect: 'postgres' }or just add it to the index.js file in the models directory of the sequelize project like this:
const sequelize = new Sequelize(config.development.url, {dialect: 'postgres', });