kysely-org / kysely

A type-safe typescript SQL query builder
https://kysely.dev
MIT License
10.71k stars 271 forks source link

cannot pass an existing pool to PostgresDialect #81

Closed DanielFGray closed 2 years ago

DanielFGray commented 2 years ago

for example in my app I use express-session and connect-pg-simple, the latter requires passing a pg pool

ideally I would like to re-use that pool when creating a kysely instance rather than creating a new pool

koskimas commented 2 years ago

This issue is formatted like a bug report 😄

As a new feature this is a good idea though. I'll make this possible soon.

koskimas commented 2 years ago

Once the next version is released, you can do this:

import { Pool } from 'pg'

const pool = new Pool(config)

const db = new Kysely<DB>({
  dialect: new PostgresDialect(pool)
})
koskimas commented 2 years ago

Released in 0.18.1