Helper for dynamically resolving the repository to use.
This module provides functions to get the appropriate repository based on configuration. It will use the configured repo from the parent application if available, otherwise fall back to the built-in PhoenixKit.Repo for development/testing.
Summary
Functions
Delegates to the configured repo's aggregate function.
Delegates to the configured repo's all function.
Delegates to the configured repo's delete function.
Delegates to the configured repo's delete_all function.
Delegates to the configured repo's exists? function.
Delegates to the configured repo's get function.
Delegates to the configured repo's get! function.
Delegates to the configured repo's get_by function.
Returns the primary key column name for a given table.
Delegates to the configured repo's insert function.
Delegates to the configured repo's insert! function.
Delegates to the configured repo's one function.
Delegates to the configured repo's preload function.
Delegates to the configured repo's query function.
Delegates to the configured repo's query! function.
Gets the repository module to use.
Delegates to the configured repo's rollback function.
Delegates to the configured repo's transaction function.
Delegates to the configured repo's update function.
Functions
Delegates to the configured repo's aggregate function.
Delegates to the configured repo's all function.
Delegates to the configured repo's delete function.
Delegates to the configured repo's delete_all function.
Delegates to the configured repo's exists? function.
Delegates to the configured repo's get function.
Delegates to the configured repo's get! function.
Delegates to the configured repo's get_by function.
Returns the primary key column name for a given table.
Looks up the table's primary key by querying pg_index. Uses Postgres'
to_regclass/1 so the table name can be passed as a bind parameter
(search-path aware, returns NULL when the table doesn't exist) — Postgrex
can't bind a text parameter to a regclass cast directly.
Returns
column_name :: String.t()when the table has a single-column primary key.
Raises
ArgumentErrorwhen the table doesn't exist, has no primary key, or has a composite primary key (this helper only supports single-column PKs; callers buildingON CONFLICTclauses must handle composite PKs explicitly).- Any error raised by the underlying repo query (e.g.
Postgrex.Error).
Previously this function silently returned "id" on any failure, which
masked the fact that every shipped PhoenixKit schema uses uuid as its
primary key — see issue #517.
Delegates to the configured repo's insert function.
Delegates to the configured repo's insert! function.
Delegates to the configured repo's one function.
Delegates to the configured repo's preload function.
Delegates to the configured repo's query function.
Delegates to the configured repo's query! function.
Gets the repository module to use.
Expects repo to be configured via PhoenixKit.Config.get(:repo). Raises an error if no repo is configured.
Delegates to the configured repo's rollback function.
This function is used within transactions to rollback and return an error value.
Delegates to the configured repo's transaction function.
Delegates to the configured repo's update function.