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

Compile-time configuration of a schema that uses `AncestryEx`.

A config is built by `use AncestryEx` and can be retrieved at runtime with
`MySchema.__ancestry__/0`. See `AncestryEx` for the list of options.

# `orphan_strategy`

```elixir
@type orphan_strategy() :: :destroy | :rootify | :adopt | :restrict | :none
```

# `t`

```elixir
@type t() :: %AncestryEx.Config{
  column: atom(),
  counter_cache_column: atom() | nil,
  depth_column: atom() | nil,
  depth_mode: :stored | :virtual | nil,
  format: AncestryEx.Format.t(),
  orphan_strategy: orphan_strategy(),
  schema: module(),
  touch: boolean()
}
```

# `cast_id`

```elixir
@spec cast_id(t(), term()) :: {:ok, term()} | :error
```

Casts a value (usually a segment of the ancestry string) to the primary key type.

# `fetch!`

```elixir
@spec fetch!(module() | struct()) :: t()
```

Returns the config of the given schema module or struct.

# `new!`

```elixir
@spec new!(module(), keyword()) :: t()
```

Builds and validates a config for `schema`. Raises `ArgumentError` on invalid options.

# `primary_key`

```elixir
@spec primary_key(t()) :: atom()
```

Returns the primary key field of the schema. Only single-column keys are supported.

# `primary_key_type`

```elixir
@spec primary_key_type(t()) :: Ecto.Type.t()
```

Returns the Ecto type of the primary key.

---

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