mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 20:34:03 +00:00
22 lines
434 B
TypeScript
22 lines
434 B
TypeScript
import postgres from 'postgres'
|
|
import { drizzle } from 'drizzle-orm/postgres-js'
|
|
|
|
export interface DbClientOptions {
|
|
max?: number
|
|
prepare?: boolean
|
|
}
|
|
|
|
export function createDbClient(databaseUrl: string, options: DbClientOptions = {}) {
|
|
const queryClient = postgres(databaseUrl, {
|
|
max: options.max ?? 5,
|
|
prepare: options.prepare ?? false
|
|
})
|
|
|
|
const db = drizzle(queryClient)
|
|
|
|
return {
|
|
db,
|
|
queryClient
|
|
}
|
|
}
|