Ash.Query.load not loading nested relationship?
this gives an invalid load BUT:
works fine? Why can't I load nested on the parent many_to_many relationship?
6 Replies
Can I see the friendships relationship?
additional maybe unrelated context:
It's sort of a strange design I guess, since I'd like to represent a friendship between two users in the form of having a join table that contains both users and then a type that would signify the type of friendship basically like requests and blocking.
So the type would be something like first_request_second, second_request_first, mutual, first_block_second, second_block_first, mutual_block etc.
instead of making separate tables for requests and blocking and link them I think I can do it all in one type.
you're trying to load relationships that are on the join resource it seems like?
Set the join relationship in the many to many, something like
join_relationship :friendship_links
and then load that, as opposed to friendships
What you probably want is actually many_to_many :friends, ...
and then the join relationship would be called :friendships
and then your load statement will work as intendedIf I understand you correctly I need to create a many_to_many inside of my join table called something like
:friendship_links
and then my query will look something like
?ah, no not quite
A
many_to_many
relationship actually consists of two relationships
a has_many
relationship is created automatically under the hood, with _join_relationship
appended to the name of the many_to_many
if you want to load the join entries, that is the relationship that you would load
so if you changed your thing to load(friendship_join_relationship: [:first, :second])
then it would do what you want
And then if you were to change the many_to_many
relationship name to friends
and set join_relationship :friendships
Then you could do what you originally wanted to do (and I think that's what you want)ok thank u i'll give it a shot