mirror of
https://github.com/bitbaum/heidi.git
synced 2026-12-04 14:17:25 +01:00
Claude-Session: https://claude.ai/code/session_019MDtmvb6xi489TfZMg7n9T Co-authored-by: Claude <noreply@anthropic.com>
16 lines
726 B
TypeScript
16 lines
726 B
TypeScript
import { getDb } from "./index.ts";
|
|
|
|
/**
|
|
* One parameterised statement, its rows back.
|
|
*
|
|
* The narrowest way to reach the database, for the few modules whose whole
|
|
* job is a statement or two (the rate counter, the error sink, the owner's
|
|
* numbers). They take a `Run` instead of importing the pool, so their tests
|
|
* hand them an in-process Postgres built from the migration files and the
|
|
* statement that is tested is the statement that ships.
|
|
*/
|
|
export type Run = (text: string, params: readonly unknown[]) => Promise<readonly Record<string, unknown>[]>;
|
|
|
|
/** The app's pool. Built on first use, like `getDb`. */
|
|
export const run: Run = async (text, params) => (await getDb().$client.query(text, [...params])).rows;
|