You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Say I have a collection of categories, how would I go about eager loading all of their root categories (unless they're the root categories themselves) in one query?
The text was updated successfully, but these errors were encountered:
pugsiman
changed the title
How would one go about eager loading a categories collection's root categories
How would one go about eager loading a categories collection's root categories?
Nov 14, 2018
While solving similar problem, I've ended up using association through scenic view
I have created an SQL view which looked something like this:
SELECT
DISTINCT ON (descendant_id)
ancestor_id AS root_id,
descendant_id AS leaf_id,
generations AS depth
FROM category_hierarchies
ORDER BY descendant_id, generations DESC
Then I defined a read-only model which uses this view:
Say I have a collection of categories, how would I go about eager loading all of their root categories (unless they're the root categories themselves) in one query?
The text was updated successfully, but these errors were encountered: