Setting Sequelize associations in Node - Postman throwing constraint errors #13175
Unanswered
JimboGeesus
asked this question in
Help & Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Apologies if this is very basic for this group but I am trying to set my Sequelize associations correctly so that all my "include" data is pulled when I make requests. I have seen the information in the docs relating to this however it is a bit hard to understand without seeing it in an app.
I previously had associations in however they never pulled the foreign key values and I only had "include all" in the API's. I now have more specific "include: ["articleType"] at the start of my data pulls. As I am working without migrations I am not sure if I am updating pgAdmin correctly (I am only putting foreign keys in for ones that I am able as making a foreign key out of a primary key is not allowed due to the unique constraint error).
Firstly in PGadmin how should I reflect the constraints that I have in my models? can these be done manually? I can't see the manyToMany, belongTo etc only the simple foreign key restraint to a primary key on another table.
Secondly, on my models below do I need keys declared on both related models?
article model
articleType model
article controller
Beta Was this translation helpful? Give feedback.
All reactions