Fetching descendants in calculation
I've created a
listings
resource/table which is nestable via a parent_listing_id
attribute. In a calculation I want to find all descendants for a listing, what's the best way to do this?4 Replies
I thought about just translating a query similar to the following to ecto and then passing it the list of record ids in the calculation, but maybe there's a better way?
i have this in one of my resources
Not sure if it is better though 😉
I think it's better at least in that you can look at the resource and know the current state of that SQL statement instead of digging through migrations to figure it out.
I might suggest using a manual relationship
it would look similar, but if you use the ash postgres features for manual relationships then you'll be able to filter/join on it/use it in other calculations