import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as schema from "./schema.js";

export function createDb(url: string, max = 10) {
	const client = postgres(url, { max, onnotice() {} });
	return { db: drizzle(client, { schema }), client };
}

export type Database = ReturnType<typeof createDb>["db"];
