Hierarchy checks
Ancestor / descendant containment between two paths. Both lower to native ltree operators and return a boolean.
| path.isAncestorOf(rhs) | ltree @> ltree |
| path.isDescendantOf(rhs) | ltree <@ ltree |
// Every category under "Top.Science"
const plan = sql
.from(tables.category)
.select({ id: tables.category.columns.id })
.where(
tables.category.columns.path.isDescendantOf(param("prefix")),
)
.build({ params: { prefix: "Top.Science" } });