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
| Property | Type | Description |
|---|---|---|
driver | 'postgrejs' | The driver name, matched against ClientConfiguration.driver. |
dialect | 'postgres' | The dialect name, matched against ClientConfiguration.dialect. |
features | Adapter.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.
Other exports
| Export | Description |
|---|---|
version | This package's own version string (e.g. "6.3.0"), kept in step with package.json. |
PgCursor | The Adapter.Cursor returned for cursor queries — a PostgreJS Cursor adapted to SQB's rowType convention ('array' or 'object'). Created via PgCursor.create(cursor), which chains a small wrapper onto the live PostgreJS cursor so its internal state stays intact (fixed in v6.0.10 — earlier releases broke next()/close() on Postgres cursors). |
See also
- PostgreSQL adapter guide
AdapterinterfaceAdapterRegistry