Hey 👋
postgres
released version 3.4, and with it the ability to reserve a single connection in the pool.
This means it is 100% aligned with kysely
's internals, and this dialect no longer has caveats with single connection executions and transactions.
They work without possibly creating more connection to the database than passed in options max.
Breaking changes:
Now that the dialect no longer has to create pools of 1 as a workaround for the caveats, it can simply accept a postgres
instance,
instead of connection options and the postgres
function.
Migrating from v1:
-
Install postgres >= 3.4.0
-
Change your instantiation code to look like this:
import {Kysely} from 'kysely'
import {PostgresJSDialect} from 'kysely-postgres-js'
import postgres from 'postgres'
const db = new Kysely<Database>({
dialect: new PostgresJSDialect({
postgres: postgres({
database: 'test',
host: 'localhost',
max: 10,
port: 5434,
user: 'admin',
}),
}),
})