Recursive queries over a self-referencing table — a schema whose rows
point at a parent row of the same schema (parent_uuid by default).
Each call is one recursive CTE: subtrees for cascades and moves,
ancestors for breadcrumbs and cycle checks.
Cycle-safe: the CTEs use UNION, not UNION ALL, so Postgres drops rows
it has already seen and a corrupt parent cycle ends the recursion instead
of looping.
Uuids come back as strings, in no particular order. An argument that is
not a uuid names no row ([]), rather than raising.
TreeQuery.subtree_uuids(Category, [category.uuid])
TreeQuery.ancestor_uuids(Space, space.uuid, parent: :parent_space_uuid)Options
:parent— the parent-id field (default:parent_uuid):repo— the repo (defaultPhoenixKit.RepoHelper.repo/0)
Summary
Functions
Every row above uuid, up to the top — not uuid itself.
Every row below uuid, not uuid itself. [] for a leaf.
roots and every row below them — the union of their subtrees, each
uuid once. [] for no roots.
Functions
Every row above uuid, up to the top — not uuid itself.
Every row below uuid, not uuid itself. [] for a leaf.
roots and every row below them — the union of their subtrees, each
uuid once. [] for no roots.