# `mix ancestry_ex.gen.context`
[🔗](https://github.com/rocket4ce/ancestry_ex/blob/v0.1.0/lib/mix/tasks/ancestry_ex.gen.context.ex#L1)

Generates a context module with functions to work with a tree, along with
its schema and migration (see `mix ancestry_ex.gen.schema`).

    $ mix ancestry_ex.gen.context Catalog Category categories name:string

Generates `MyApp.Catalog` with `list_categories/0`, `list_root_categories/0`,
`list_category_children/1`, `list_category_ancestors/1`, `category_tree/0`,
`category_subtree/1`, `get_category!/1`, `create_category/1`,
`update_category/2`, `move_category/2`, `delete_category/1` and
`change_category/2`.

If the context module already exists, the functions are appended to it.
Function names come from the plural name (`categories`), the table name
can be changed with `--table`.

Accepts the same options as `mix ancestry_ex.gen.schema`.

---

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