Isn't this circular dependency #4979
Unanswered
SerdarSanri
asked this question in
Help
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
@thetutlage I know you are gonna roast me on this but just for my sanity I had to ask. I am trying to wrap my head around something from day one I couldn't understand the logic behind it. I am very sorry for my ignorance on this but if you can explain a bit more on this model to model relationships that would be really helpful. I am on v5 btw.
So for instance I have a User, Role and Permission models. Each has their own structure and share a foreign key. User has a role_id.
and
when defining relationships in User model you would say
but also you can define
so because we are referring Role in User table we will add
import Role from '#app/models/RoleModel
then in RoleModel, we would addimport User from '#app/models/UserModel
This is the part where I get really confused. Isn't this the textbook definition of circular dependency? Should this kind of relationship definitions be avoided? But if so, how can you get all the users' in a role or role of a user?
Above is not real code but just pseudo to explain what I am trying to understand.
Beta Was this translation helpful? Give feedback.
All reactions