mix ancestry_ex.gen.context (ancestry_ex v0.1.0)

Copy Markdown View Source

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.