gloo/adapter
Adapter — the sole DB-specific layer (V12).
execute_query and run_transaction dispatch to the correct backend
based on the DbConnection variant. repo, query, sql, and
validate modules never import pog or sqlight directly.
Types
pub type Adapter {
Adapter(
name: String,
connection: DbConnection,
quote_identifier: fn(String) -> String,
placeholder: fn(Int) -> String,
savepoint_depth: Int,
telemetry: telemetry.Telemetry,
)
}
Constructors
-
Adapter( name: String, connection: DbConnection, quote_identifier: fn(String) -> String, placeholder: fn(Int) -> String, savepoint_depth: Int, telemetry: telemetry.Telemetry, )
pub type DbConnection {
PgConnection(conn: pog.Connection, pid: process.Pid)
SqConnection(sqlight.Connection)
}
Constructors
-
PgConnection(conn: pog.Connection, pid: process.Pid) -
SqConnection(sqlight.Connection)
pub type ExecuteResult {
ExecuteResult(rows: List(dynamic.Dynamic), count: Int)
}
Constructors
-
ExecuteResult(rows: List(dynamic.Dynamic), count: Int)
Values
pub fn close(adapter: Adapter) -> Result(Nil, String)
Close the underlying connection. Stops the pog pool process for Postgres, releasing all held connections. Idempotent: calling twice is safe.
pub fn execute_query(
adapter: Adapter,
sql: String,
params: List(value.GlooValue),
) -> Result(ExecuteResult, error.GlooError)
pub fn postgres_placeholder(n: Int) -> String
pub fn postgres_quote(identifier: String) -> String
pub fn run_transaction(
adapter: Adapter,
callback: fn(Adapter) -> Result(a, String),
) -> Result(a, error.GlooError)
V5/V6: run a top-level transaction (savepoint_depth == 0). Ok → commit; Error → rollback.
pub fn sqlite_placeholder(n: Int) -> String
SQLite uses ? — parameters are bound positionally.
The sql/query modules always produce $N; we convert at execution time.
pub fn sqlite_quote(identifier: String) -> String