# `AncestryEx.Query`
[🔗](https://github.com/rocket4ce/ancestry_ex/blob/v0.1.0/lib/ancestry_ex/query.ex#L1)

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.

# `after_depth`

Nodes with depth greater than `depth`.

# `ancestors`

Ancestors of `node`, ordered from the root down to the parent.

# `at_depth`

Nodes with depth equal to `depth`.

# `before_depth`

Nodes with depth lower than `depth`.

# `children`

Direct children of `node`.

# `depth_expr`

```elixir
@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.

# `descendants`

All nodes below `node`.

# `from_depth`

Nodes with depth greater than or equal to `depth`.

# `indirects`

Descendants of `node` that are not direct children.

# `leaves`

Nodes without children.

# `ordered_by_ancestry`

Orders by the ancestry column, roots first. Parents are always returned
before their children, which is what `AncestryEx.arrange/1` needs.

# `parent`

The parent of `node` (no rows for a root).

# `path`

Ancestors of `node` plus the node itself, ordered from the root down.

# `root`

The root of the tree `node` belongs to (the node itself for a root).

# `roots`

```elixir
@spec roots(Ecto.Queryable.t(), AncestryEx.Config.t()) :: Ecto.Query.t()
```

Root nodes.

# `siblings`

Nodes sharing the parent of `node`, excluding `node`. Roots are siblings of each other.

# `subtree`

`node` and all nodes below it.

# `to_depth`

Nodes with depth lower than or equal to `depth`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
