IF Commons GitHub

physical/adapters/pg

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-sql-port FR-008

The port of a PostgreSQL server reached by pg: a pool (each transaction takes a connection of its own, so that writers run side by side and the row locks of the database decide between them) or one client (one transaction at a time). It is typed by the shape of query and connect, so that this library depends on no client. pg gives a BIGINT as text and bytes as a buffer: both are read as the port reads values.

import { pgPort } from "@intellectual-frontiers/anyfs-sql/pg";
// const port = pgPort(new Pool({ connectionString })); // the credentials are the caller's, never part of a place

Source: commons/anyfs-sql/src/physical/adapters/pg.ts

2 of 7 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

PgResultinterfaceno test imports it
interface PgResult

What query gives.

MemberTypeWhat it is
rowsreadonly unknown[]
PgQueryableinterfaceno test imports it
interface PgQueryable

What runs one statement: a client, a pool or a connection taken from a pool.

MemberTypeWhat it is
query(text: string, values?: SqlValue[] | undefined) => Promise<PgResult>
PgPoolClientinterfaceno test imports it
interface PgPoolClient extends PgQueryable

A connection taken from a pool.

MemberTypeWhat it is
release(error?: boolean | Error | undefined) => void
query(text: string, values?: SqlValue[] | undefined) => Promise<PgResult>
PgPoolinterfaceno test imports it
interface PgPool extends PgQueryable

A pool of connections.

MemberTypeWhat it is
connect() => Promise<PgPoolClient>
end() => Promise<void>
query(text: string, values?: SqlValue[] | undefined) => Promise<PgResult>
PgClientinterfaceno test imports it
interface PgClient extends PgQueryable

One client.

MemberTypeWhat it is
end() => Promise<void>
query(text: string, values?: SqlValue[] | undefined) => Promise<PgResult>
pgPortfunction
function pgPort(pool: PgPool): SqlPort

The port of a pool: a transaction takes a connection and gives it back.

Imported by 10 tests of the run (10 passed, 0 failed): the library's results

pgClientPortfunction
function pgClientPort(client: PgClient): SqlPort

The port of one client: a transaction at a time.

Imported by 10 tests of the run (10 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.