Shared utilities for database queries.
Provides RPC-style PostgreSQL function calls, UUID handling, row-to-map conversion, time range calculations, and status conversions.
Used by both PgFlow core query modules and the PgFlow Dashboard.
Summary
Functions
Converts a direction atom to string for database queries.
Executes an RPC-style call to a PostgreSQL function.
Formats a binary UUID to string representation.
Converts a health status atom or string to string for database queries.
Parses a UUID string to binary format for database queries.
Converts a status atom or string to string for database queries.
Converts a time range atom to a start DateTime.
Functions
Converts a direction atom to string for database queries.
@spec execute_rpc(module(), String.t(), list(), keyword()) :: {:ok, nil | map() | [map()]} | {:error, :not_found | term()} | [map()] | integer()
Executes an RPC-style call to a PostgreSQL function.
Parameters
repo- The Ecto repositoryfunction_name- Name of the PostgreSQL functionparams- List of parameters to passopts- Options keyword list
Options
:schema- (required) The PostgreSQL schema containing the function:mode- Result handling mode::list,:single,:count,:void,:raw
Returns
Depends on mode:
:list- Returns list of maps:single- Returns{:ok, map}or{:error, :not_found}:count- Returns integer count:void- Returns{:ok, nil}:raw- Returns{:ok, list of maps}or error
Formats a binary UUID to string representation.
Converts a health status atom or string to string for database queries.
Parses a UUID string to binary format for database queries.
Converts a status atom or string to string for database queries.
@spec time_range_start(atom()) :: DateTime.t()
Converts a time range atom to a start DateTime.