# `Jido.Ecto.Storage`
[🔗](https://github.com/agentjido/jido_ecto/blob/v1.0.0/lib/jido_ecto/storage.ex#L1)

Ecto-backed `Jido.Storage` adapter.

The adapter persists three logical records:

- checkpoints in `jido_checkpoints`
- thread state snapshots in `jido_threads`
- ordered thread journal entries in `jido_thread_entries`

Create those tables with `Jido.Ecto.Migrations.create_storage_tables/1`.

Required options:

- `:repo` - an `Ecto.Repo` module

Optional repo options passed through to queries:

- `:prefix`
- `:timeout`
- `:log`
- `:telemetry_event`
- `:telemetry_options`

`append_thread/3` also accepts:

- `:expected_rev` - optimistic concurrency guard
- `:metadata` - thread metadata used only when the thread is first created

# `thread_state`

```elixir
@type thread_state() :: %{
  rev: non_neg_integer(),
  created_at_ms: integer(),
  updated_at_ms: integer(),
  persisted?: boolean(),
  metadata: map(),
  entries: [Jido.Thread.Entry.t()]
}
```

---

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