Open ShaggyDev opened 8 years ago
Hum, I think what you're trying to do is the same as in https://github.com/neumino/thinky/issues/421#issuecomment-171334263. Thinky doesn't support non bi-directional relations at the moment.
Ahh I see, I figured that might be the case but thought I would try it out anyway ;D. From the issue you linked to, it looks like I am setting up the two hasAndBelongsToMany relations in exactly the same way. The only problem with the implementation is that there isn't an explicit way of deriving that any given node is definitely a child of another node and not the parent and vise-versa. I am unsure of how the OP from issue #421 is using that architecture and still able to determine if a given user is only following the other user, or if he/she is only being followed by the other user, or both following and being followed by the other user. I took a look at the data that is generated within the tables that are created by these relationships and as they are fairly simplistic in nature, it still takes a lot of assumptions about the data to derive more information about the relationship. As for now, utilizing these n-n tables, for now, is going to be the way to continue using this method of relating models to themselves and understanding their non bi-directional relations then? For what I will be using this for, I might be able to get away with another implementation since these relations will not be so dynamic as user friendships are ;D
I am attempting to use the n-n relation using hasAndBelongsToMany() in thinky to define circular relations as "parents" and "children". Although the feature is working, I was wondering if there is a way that I can retrieve these circular relations as they were defined/saved, where in the below example, nodes saved in another node as a
parent
would only show up in the child node'sparents
field and not also in thechildren
field of the same node as well as the root parent node only containing the children in thechildren
field while the root parent node would have no objects contained in it'sparents
field. I hope the below test case code makes sense and illustrates my explanation.