# `CommBus.Storage.EctoAdapter`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

Generic helper that persists CommBus entries and conversations using any Ecto repo.

The adapter expects a configuration map with the following keys:

  * `:repo` - Ecto repo module implementing `insert_or_update/1`, `all/1`, `get/2`, `delete/1`
  * `:entry_schema` - schema module with `changeset/2` (or rely on `Ecto.Changeset.change/2`)
  * `:conversation_schema` - schema module for conversations

This module does not implement the behaviours directly; instead, concrete modules
(e.g. `CommBus.Storage.DevMan`) delegate to it.

# `config`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@type config() :: %{
  repo: module(),
  entry_schema: module(),
  conversation_schema: module()
}
```

# `delete_entry`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec delete_entry(term(), config()) :: :ok | {:error, term()}
```

Deletes an entry by ID from the database.

## Parameters

  - `id` — The entry identifier.
  - `config` — Adapter config map.

## Returns

`:ok` on success, or `{:error, reason}` on failure.

# `get_entry`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec get_entry(term(), config()) :: {:ok, CommBus.Entry.t()} | {:error, :not_found}
```

Fetches a single entry by ID from the database.

## Parameters

  - `id` — The entry identifier.
  - `config` — Adapter config map.

## Returns

`{:ok, %CommBus.Entry{}}` if found, or `{:error, :not_found}`.

# `list_entries`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec list_entries(
  keyword(),
  config()
) :: {:ok, [CommBus.Entry.t()]} | {:error, term()}
```

Loads all entries from the database via the configured repo and schema,
applying optional filters.

## Parameters

  - `opts` — Keyword filters: `:enabled`, `:mode`, `:keywords`.
  - `config` — Adapter config map with `:repo`, `:entry_schema`, `:conversation_schema`.

## Returns

`{:ok, [%CommBus.Entry{}]}` with the matching entries.

# `load_conversation`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec load_conversation(term(), config()) ::
  {:ok, CommBus.Conversation.t()} | {:error, :not_found}
```

Fetches a conversation by ID from the database.

## Parameters

  - `id` — The conversation identifier.
  - `config` — Adapter config map.

## Returns

`{:ok, %CommBus.Conversation{}}` if found, or `{:error, :not_found}`.

# `store_conversation`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec store_conversation(CommBus.Conversation.t(), config()) ::
  {:ok, CommBus.Conversation.t()} | {:error, term()}
```

Persists a `%CommBus.Conversation{}` struct via the configured Ecto repo.

## Parameters

  - `conversation` — A `%CommBus.Conversation{}` struct to persist.
  - `config` — Adapter config map.

## Returns

`{:ok, %CommBus.Conversation{}}` on success or `{:error, reason}` on failure.

# `store_entry`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec store_entry(CommBus.Entry.t(), config()) ::
  {:ok, CommBus.Entry.t()} | {:error, term()}
```

Persists a `%CommBus.Entry{}` struct via the configured Ecto repo, upserting
the record through the entry schema's changeset.

## Parameters

  - `entry` — A `%CommBus.Entry{}` struct to persist.
  - `config` — Adapter config map with `:repo`, `:entry_schema`, `:conversation_schema`.

## Returns

`{:ok, %CommBus.Entry{}}` on success or `{:error, reason}` on failure.

# `update_conversation`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec update_conversation(term(), map(), config()) ::
  {:ok, CommBus.Conversation.t()} | {:error, term()}
```

Updates an existing conversation record with the given attributes.

## Parameters

  - `id` — The conversation identifier.
  - `updates` — A map of fields to update.
  - `config` — Adapter config map.

## Returns

`{:ok, %CommBus.Conversation{}}` on success or `{:error, reason}` on failure.

---

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