Ecto/Postgres adapter for PhoenixAI.Store.Adapter.
All callbacks receive an opts keyword list containing a :repo key
pointing to the Ecto.Repo module to use for queries.
This module is only compiled when Ecto is available as a dependency.
Summary
Functions
Inserts a message row into the database. Returns {:error, :not_found} if the conversation does not exist.
Checks whether a conversation exists in the database using Repo.exists?/1.
Counts conversation rows matching the given filters using a database COUNT query.
Counts event rows matching the given filters using a database COUNT query.
Counts fact rows for a user using a database COUNT query.
Deletes a conversation row from the database. Returns {:error, :not_found} if absent.
Deletes all fact rows matching {user_id, key} from the database.
Deletes all profile rows for a user from the database.
Queries all cost records for a conversation from the database, ordered by recorded_at ascending.
Queries all facts for a user from the database, ordered by inserted_at ascending.
Queries all messages for a conversation from the database, ordered by inserted_at ascending.
Queries conversations from the database with optional filters, ordered by inserted_at descending.
Queries a paginated, filtered list of events from the database with an opaque cursor for the next page.
Loads a conversation by ID from the database, preloading messages ordered by inserted_at.
Loads a user profile from the database. Returns {:error, :not_found} if absent.
Inserts an event row into the database. The event log is append-only — no updates or deletes.
Inserts or updates a conversation row in the database via the configured Repo.
Inserts a cost record row into the database. Records are immutable once written.
Upserts a fact row in the database using ON CONFLICT DO UPDATE on {user_id, key}.
Upserts a profile row in the database using ON CONFLICT DO UPDATE on user_id.
Sums token_count for all messages in a conversation using a database SUM aggregate.
Sums total_cost across cost records matching the given filters using a database SUM aggregate.
Sums token_count across all messages in all conversations belonging to a user via a database join.
Functions
Inserts a message row into the database. Returns {:error, :not_found} if the conversation does not exist.
Checks whether a conversation exists in the database using Repo.exists?/1.
Counts conversation rows matching the given filters using a database COUNT query.
Counts event rows matching the given filters using a database COUNT query.
Counts fact rows for a user using a database COUNT query.
Deletes a conversation row from the database. Returns {:error, :not_found} if absent.
Deletes all fact rows matching {user_id, key} from the database.
Deletes all profile rows for a user from the database.
Queries all cost records for a conversation from the database, ordered by recorded_at ascending.
Queries all facts for a user from the database, ordered by inserted_at ascending.
Queries all messages for a conversation from the database, ordered by inserted_at ascending.
Queries conversations from the database with optional filters, ordered by inserted_at descending.
Queries a paginated, filtered list of events from the database with an opaque cursor for the next page.
Loads a conversation by ID from the database, preloading messages ordered by inserted_at.
Loads a user profile from the database. Returns {:error, :not_found} if absent.
Inserts an event row into the database. The event log is append-only — no updates or deletes.
Inserts or updates a conversation row in the database via the configured Repo.
Inserts a cost record row into the database. Records are immutable once written.
Upserts a fact row in the database using ON CONFLICT DO UPDATE on {user_id, key}.
Upserts a profile row in the database using ON CONFLICT DO UPDATE on user_id.
Sums token_count for all messages in a conversation using a database SUM aggregate.
Sums total_cost across cost records matching the given filters using a database SUM aggregate.
Sums token_count across all messages in all conversations belonging to a user via a database join.