14 lines
421 B
TypeScript
14 lines
421 B
TypeScript
import { drizzle, type NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
import { Pool } from "pg";
|
|
import * as schema from "./schema.js";
|
|
|
|
export * from "./schema.js";
|
|
|
|
export type DB = NodePgDatabase<typeof schema>;
|
|
|
|
export function createClient(databaseUrl: string): { db: DB; pool: Pool } {
|
|
const pool = new Pool({ connectionString: databaseUrl });
|
|
const db = drizzle(pool, { schema });
|
|
return { db, pool };
|
|
}
|