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 implementinginsert_or_update/1,all/1,get/2,delete/1:entry_schema- schema module withchangeset/2(or rely onEcto.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.
Summary
Functions
Deletes an entry by ID from the database.
Fetches a single entry by ID from the database.
Loads all entries from the database via the configured repo and schema, applying optional filters.
Fetches a conversation by ID from the database.
Persists a %CommBus.Conversation{} struct via the configured Ecto repo.
Persists a %CommBus.Entry{} struct via the configured Ecto repo, upserting
the record through the entry schema's changeset.
Updates an existing conversation record with the given attributes.
Types
Functions
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.
@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}.
@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.
@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}.
@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.
@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.
@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.