Skip to main content

PgAdapter

PgAdapter is the Adapter implementation shipped by @sqb/postgres, connecting to PostgreSQL via PostgreJS. It self-registers with AdapterRegistry as a side effect of importing @sqb/postgres — see the PostgreSQL adapter guide for setup and configuration.

import '@sqb/postgres';

Constructor

new PgAdapter()

Takes no arguments. You normally never construct this directly — importing @sqb/postgres registers a shared instance with AdapterRegistry for you.

Properties

PropertyTypeDescription
driver'postgrejs'The driver name, matched against ClientConfiguration.driver.
dialect'postgres'The dialect name, matched against ClientConfiguration.dialect.
featuresAdapter.Features{ cursor: true, schema: true, positionalParams: true, fetchAsString: [DataType.DATE, DataType.TIMESTAMP, DataType.TIMESTAMPTZ] }.

Methods

connect()

connect(config: ClientConfiguration): Promise<Adapter.Connection>

Opens one physical PostgreJS connection. config.host, .port, .user, .password, .database, and .schema are mapped onto PostgreJS's ConnectionConfiguration; anything set in config.driverOptions is spread onto that same object first. Returns a PgConnection wrapping the opened PostgreJS connection, closing it and rethrowing if the connection attempt fails.

See also