# `BoxTurtle.Schema.Change.API`
[🔗](https://github.com/twajjo/box_turtle/blob/v0.1.0/lib/schema/change/api.ex#L1)

Write operations generated by `use BoxTurtle.Schema.Change`: create, update and delete.

The counterpart to `BoxTurtle.Schema.Query.API`, with the idea that nothing outside a Query or Change module
touches the Repo. Plain functions return `{:ok, struct}` / `{:error, changeset}` like `Ecto.Repo`; `!`
functions return the struct or raise.

# `attrs`

```elixir
@type attrs() :: map() | schema()
```

# `key`

```elixir
@type key() :: term()
```

# `schema`

```elixir
@type schema() :: Ecto.Schema.t()
```

# `create`

```elixir
@callback create(attrs() | Ecto.Changeset.t()) ::
  {:ok, schema()} | {:error, Ecto.Changeset.t()}
```

Inserts a changeset, or a changeset built from a map (or struct) of attributes.

# `create!`

```elixir
@callback create!(attrs() | Ecto.Changeset.t()) :: schema()
```

# `delete`

```elixir
@callback delete(key() | schema() | Ecto.Changeset.t()) ::
  {:ok, schema()} | {:error, Ecto.Changeset.t() | :not_found}
```

Deletes a struct, a changeset, or the row with the given primary key (`{:error, :not_found}` if absent).

# `delete!`

```elixir
@callback delete!(key() | schema() | Ecto.Changeset.t()) :: schema()
```

# `update`

```elixir
@callback update(Ecto.Changeset.t()) :: {:ok, schema()} | {:error, Ecto.Changeset.t()}
```

Updates a changeset, or a struct with a map of changes.

# `update`

```elixir
@callback update(schema(), map()) :: {:ok, schema()} | {:error, Ecto.Changeset.t()}
```

# `update!`

```elixir
@callback update!(Ecto.Changeset.t()) :: schema()
```

# `update!`

```elixir
@callback update!(schema(), map()) :: schema()
```

---

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