-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to defined relations among the models #42
Comments
Hi, could you provide your error and if possible an example of your app ? This project uses Sequelize to manage the database. You can find the documentation here ; Here's an example of a relationship between project and User, where each user has a project (and hence a ForeignKey to Project); If you wanted a FK from Project to User you would do
and if you wanted ManyToMany relationship you would to
Here's an extract from the doc
Hope this helps, if you still have an error please provide it ;) |
@krzepah I am sorry that I didn't gave a relative code here. States.js code is
and UserStates.js is
In Controller file i am querying as below
The error is
|
I don't see any part of the doc that specify the usage of .associate, maybe i'm wrong and someone could correct me up; If I understand your problem properly I would go with something along the line of
Instead of
This stackoverflow question might hint that the behaviour was depreciated but I cannot find any note about it in the release-notes ; I couldn't really track down any more intel regarding usage of .associate ; please try without it :) |
hi @anjil , can you try to change the code in controller into this
since you using States, not State. |
@ace3 / @aichbauer can you help me how can I setup the 1:1, 1:N relations in this setup. I am not able to do it and getting error. Please help.
The text was updated successfully, but these errors were encountered: