arbor v1.1.1 Arbor.Tree View Source

Using Arbor.Tree will add common tree traversal functions to your Ecto model.

Examples

defmodule Comment do
  use Ecto.Schema
  use Arbor.Tree,
    table_name: "comments",
    tree_name: "comments_tree",
    primary_key: :id,
    primary_key_type: :id,
    foreign_key: :parent_id,
    foreign_key_type: :id
    orphan_strategy: :nothing

  schema "comments" do
    field :body, :string
    belongs_to :parent, Arbor.Comment

    timestamps()
  end
end