| 17 | export type DrizzleClient = ReturnType<typeof createDrizzleClient>; |
| 18 | |
| 19 | export function createDrizzleClient(options: CreateDrizzleClientOptions) { |
| 20 | const { connectionString, poolConfig = {}, logger = false, ssl } = options; |
| 21 | |
| 22 | const baseConfig = getDatabaseClientConfig(connectionString); |
| 23 | if (ssl !== undefined) { |
| 24 | baseConfig.ssl = ssl; |
| 25 | } |
| 26 | |
| 27 | const pool = new pg.Pool({ |
| 28 | ...baseConfig, |
| 29 | ...poolConfig, |
| 30 | }); |
| 31 | |
| 32 | const db = drizzle(pool, { schema, logger }); |
| 33 | |
| 34 | return { db, pool, schema }; |
| 35 | } |
| 36 | |
| 37 | export type GetWorkerDbOptions = Omit<pg.PoolConfig, 'connectionString' | 'max'>; |
| 38 | |