# `Tayori.Categories`
[🔗](https://github.com/hattoriai/tayori/blob/v0.1.0/lib/tayori/categories.ex#L1)

The categories of the news (`Tayori.Category`), in their order. The
admin manages them; a script or a seed can too:

    {:ok, _} = Tayori.Categories.create(%{"names" => %{"en" => "New"}, "color" => "blue"})

# `by_key`

```elixir
@spec by_key() :: %{required(String.t()) =&gt; Tayori.Category.t()}
```

The categories by key, for rendering entries.

# `change`

```elixir
@spec change(Tayori.Category.t(), map()) :: Ecto.Changeset.t()
```

A changeset of a category, for a form.

# `create`

```elixir
@spec create(map()) :: {:ok, Tayori.Category.t()} | {:error, Ecto.Changeset.t()}
```

Creates a category, at the end of the list.

# `delete`

```elixir
@spec delete(Tayori.Category.t()) ::
  {:ok, Tayori.Category.t()} | {:error, Ecto.Changeset.t()}
```

Deletes a category, and takes it off the entries that have it.

# `get`

```elixir
@spec get(String.t()) :: Tayori.Category.t() | nil
```

A category by its key, or nil.

# `list`

```elixir
@spec list() :: [Tayori.Category.t()]
```

The categories, in their order.

# `reorder`

```elixir
@spec reorder([String.t()]) :: :ok
```

Puts the categories in the order of the keys given.

# `update`

```elixir
@spec update(Tayori.Category.t(), map()) ::
  {:ok, Tayori.Category.t()} | {:error, Ecto.Changeset.t()}
```

Updates a category's names and colour. Its key stays.

---

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