Filtering many_to_many relationships

Hi all I have a many_to_many relationship between two entities (hubs and adverts). I want to have an action that takes an advert_id and returns the hubs to which it's attached to.
2 Replies
ZachDaniel
ZachDaniel2y ago
filter expr(adverts.id == ^arg(:advert_id))
filter expr(adverts.id == ^arg(:advert_id))
Or
filter expr(exists(adverts, id == ^arg(:advert_id)))
filter expr(exists(adverts, id == ^arg(:advert_id)))
I'd go with the first one, but the second one is an option as well The second one is useful when you have more complex filters for the destination
franckstifler
franckstiflerOP2y ago
wonderful! This works.

Did you find this page helpful?