Query builders used by the functions that use AncestryEx defines in a schema.
Every function receives a queryable as first argument and returns an
Ecto.Query, so results can be further composed before being sent to the repo:
Category.children(category)
|> where(active: true)
|> order_by(:name)
|> Repo.all()You normally call these through the schema (Category.children(node)), which
passes the schema config for you. The functions here take the config
explicitly and can be used with any queryable over an ancestry schema.
Summary
Functions
Nodes with depth greater than depth.
Ancestors of node, ordered from the root down to the parent.
Nodes with depth equal to depth.
Nodes with depth lower than depth.
Direct children of node.
Dynamic expression with the depth of the node, using the depth cache column when configured and computing it from the ancestry column otherwise.
All nodes below node.
Nodes with depth greater than or equal to depth.
Descendants of node that are not direct children.
Nodes without children.
Orders by the ancestry column, roots first. Parents are always returned
before their children, which is what AncestryEx.arrange/1 needs.
The parent of node (no rows for a root).
Ancestors of node plus the node itself, ordered from the root down.
The root of the tree node belongs to (the node itself for a root).
Root nodes.
Nodes sharing the parent of node, excluding node. Roots are siblings of each other.
node and all nodes below it.
Nodes with depth lower than or equal to depth.
Functions
Nodes with depth greater than depth.
Ancestors of node, ordered from the root down to the parent.
Nodes with depth equal to depth.
Nodes with depth lower than depth.
Direct children of node.
@spec depth_expr(AncestryEx.Config.t()) :: Ecto.Query.dynamic_expr()
Dynamic expression with the depth of the node, using the depth cache column when configured and computing it from the ancestry column otherwise.
All nodes below node.
Nodes with depth greater than or equal to depth.
Descendants of node that are not direct children.
Nodes without children.
Orders by the ancestry column, roots first. Parents are always returned
before their children, which is what AncestryEx.arrange/1 needs.
The parent of node (no rows for a root).
Ancestors of node plus the node itself, ordered from the root down.
The root of the tree node belongs to (the node itself for a root).
@spec roots(Ecto.Queryable.t(), AncestryEx.Config.t()) :: Ecto.Query.t()
Root nodes.
Nodes sharing the parent of node, excluding node. Roots are siblings of each other.
node and all nodes below it.
Nodes with depth lower than or equal to depth.