glimr/db/db

Database Utilities

High-level database utilities for multi-database support.

NOTE: Pool management and transactions are now in driver packages:

Values

pub fn get_connection(
  connections: List(driver.Connection),
  name: String,
) -> driver.Connection

Finds a connection by name from a list of connections. Panics with a helpful message if the connection is not found, listing all available connection names for debugging.

pub fn get_connection_safe(
  connections: List(driver.Connection),
  name: String,
) -> Result(driver.Connection, Nil)

Finds a connection by name from a list of connections. Returns Error(Nil) if the connection is not found instead of panicking. Useful when connection existence is uncertain.

pub fn validate_connections(
  connections: List(driver.Connection),
) -> Nil

Validates that all connection names are unique. Panics with a helpful message listing duplicate names if any are found. Call this during startup to catch configuration errors early.

Search Document