Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

@sms/store-postgres

Interfaces

PgClient

Defined in: packages/drivers/store/postgres/src/index.ts:6

The minimal client surface we need: pg.Pool, pg.Client and PGlite all have it.

Methods

close()?
optional close(): Promise<void>;

Defined in: packages/drivers/store/postgres/src/index.ts:9

Returns

Promise<void>

end()?
optional end(): Promise<void>;

Defined in: packages/drivers/store/postgres/src/index.ts:8

Returns

Promise<void>

query()
query(text, params?): Promise<{
  rows: Record<string, unknown>[];
}>;

Defined in: packages/drivers/store/postgres/src/index.ts:7

Parameters
ParameterType
textstring
params?unknown[]
Returns

Promise<{ rows: Record<string, unknown>[]; }>


PostgresOptions

Defined in: packages/drivers/store/postgres/src/index.ts:12

Properties

client?
optional client?: PgClient;

Defined in: packages/drivers/store/postgres/src/index.ts:14

A ready client (pg Pool/Client, PGlite). Either this or connectionString.

connectionString?
optional connectionString?: string;

Defined in: packages/drivers/store/postgres/src/index.ts:16

Creates a pg.Pool (pg must be installed).

schema?
optional schema?: string;

Defined in: packages/drivers/store/postgres/src/index.ts:18

Schema to hold this kernel’s tables — one per tenant. Default public.

Functions

openPostgresStore()

function openPostgresStore(opts): Promise<Store>;

Defined in: packages/drivers/store/postgres/src/index.ts:57

Open a Store on Postgres. With connectionString a dedicated pg.Pool is created whose connections have search_path set to the schema, so all kernels share one server safely. With a hand-made client (single connection, e.g. PGlite) the search_path is set on that connection.

Parameters

ParameterType
optsPostgresOptions

Returns

Promise<Store>


postgresDatabase()

function postgresDatabase(client, opts?): Database;

Defined in: packages/drivers/store/postgres/src/index.ts:22

Wrap a Postgres client as a Database driver.

Parameters

ParameterType
clientPgClient
opts{ owned?: boolean; schema?: string; }
opts.owned?boolean
opts.schema?string

Returns

Database