waiyaki / postgres-express-node-tutorial

Repository hosting code for the "Getting Started With NodeJS, Express and Postgres Using Sequelize" blogpost.
MIT License
278 stars 103 forks source link

SequelizeDatabaseError #1

Closed shivanandbhangari closed 7 years ago

shivanandbhangari commented 7 years ago

Nice tutorial sir, but i am getting Dequelize DatabaseError while trying to request localhost:8000/api/todos in postman. The below is the output

{ "name": "SequelizeDatabaseError", "parent": { "name": "error", "length": 115, "severity": "ERROR", "code": "42P01", "position": "13", "file": "src\backend\parser\parse_relation.c", "line": "984", "routine": "parserOpenTable", "sql": "INSERT INTO \"Todos\" (\"id\",\"title\",\"createdAt\",\"updatedAt\") VALUES (DEFAULT,'first-todo','2017-06-15 06:11:49.889 +00:00','2017-06-15 06:11:49.889 +00:00') RETURNING ;" }, "original": { "name": "error", "length": 115, "severity": "ERROR", "code": "42P01", "position": "13", "file": "src\backend\parser\parse_relation.c", "line": "984", "routine": "parserOpenTable", "sql": "INSERT INTO \"Todos\" (\"id\",\"title\",\"createdAt\",\"updatedAt\") VALUES (DEFAULT,'first-todo','2017-06-15 06:11:49.889 +00:00','2017-06-15 06:11:49.889 +00:00') RETURNING ;" }, "sql": "INSERT INTO \"Todos\" (\"id\",\"title\",\"createdAt\",\"updatedAt\") VALUES (DEFAULT,'first-todo','2017-06-15 06:11:49.889 +00:00','2017-06-15 06:11:49.889 +00:00') RETURNING *;" }

Can you please help me out to resolve this error. Thank you

waiyaki commented 7 years ago

Hey @shivanandbhangari.

After creating the db and writing the code for models and the migrations, make sure you run

sequelize db:migrate

to actually create the necessary tables in the db. Let me know if that fixes that issue.

shivanandbhangari commented 7 years ago

@waiyaki Yes it works thanks a lot Waiyaki. Super exapmle, learnt lot from this code. Thank you once again.

waiyaki commented 7 years ago

Great, thank you!

jerrychong25 commented 5 years ago

Hey @shivanandbhangari.

After creating the db and writing the code for models and the migrations, make sure you run

sequelize db:migrate

to actually create the necessary tables in the db. Let me know if that fixes that issue.

Thanks!