DEV Community

loading...

Discussion on: Getting Started with Sequelize and Postgres

Collapse
nmaxcom profile image
Carles Alcolea

A couple of things for newcomers like me who will run into some issues following the code as it is here.

If seeding the DB you get "ERROR: Migration xxxx-User.js (or wrapper) didn't return a promise", you can add async/await (since all async functions return a promise) like so:

up: async (queryInterface, Sequelize) => await queryInterface.bulkInsert('Users' .............

Another gotcha can be "ERROR: getaddrinfo ENOTFOUND postgresroot" (or similar error).
If your password contains certain symbols (like #, / etc.), it can mess up the parsing. You can either change your password, removing those symbols, or URL encode your password (you can use encodeURIComponent('pass#word')). Don't worry; you don't need to decode it. So this:
postgres://user:pass#word@endpoint.......
becomes:
postgres://user:pass%23word@endpoint.......

And you are good to go.

As an overall style, I'd advise using a more semantic/component-like folder structure
Also, that repo I just linked, is filled with gold in all kinds of NodeJS knowledge!

Thanks to the author for this article, it's been handy in starting with Sequelize :)

Collapse
nedsoft profile image
Chinedu Orie Author

Thanks a lot for sharing Carles!