# `PgFlow.Queries.Helpers`
[🔗](https://github.com/agoodway/pgflow/blob/v0.1.0/lib/pgflow/queries/helpers.ex#L1)

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.

# `direction_to_string`

```elixir
@spec direction_to_string(:next | :prev | String.t()) :: String.t()
```

Converts a direction atom to string for database queries.

# `execute_rpc`

```elixir
@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 repository
  * `function_name` - Name of the PostgreSQL function
  * `params` - List of parameters to pass
  * `opts` - 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

# `format_uuid`

```elixir
@spec format_uuid(nil | binary()) :: nil | String.t()
```

Formats a binary UUID to string representation.

# `health_status_to_string`

```elixir
@spec health_status_to_string(nil | atom() | String.t()) :: nil | String.t()
```

Converts a health status atom or string to string for database queries.

# `parse_uuid`

```elixir
@spec parse_uuid(nil | String.t() | binary()) :: nil | binary()
```

Parses a UUID string to binary format for database queries.

# `status_to_string`

```elixir
@spec status_to_string(nil | atom() | String.t()) :: nil | String.t()
```

Converts a status atom or string to string for database queries.

# `time_range_start`

```elixir
@spec time_range_start(atom()) :: DateTime.t()
```

Converts a time range atom to a start DateTime.

---

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