perf : not ask me i copy from another projeft
This commit is contained in:
+10
-2
@@ -2,5 +2,13 @@ import { drizzle } from "drizzle-orm/postgres-js";
|
||||
import postgres from "postgres";
|
||||
import * as schema from "./schema";
|
||||
|
||||
const client = postgres(process.env.DATABASE_URL!);
|
||||
export const db = drizzle(client, { schema });
|
||||
const globalForDb = globalThis as unknown as { pgClient: ReturnType<typeof postgres> };
|
||||
|
||||
if (!globalForDb.pgClient) {
|
||||
globalForDb.pgClient = postgres(process.env.DATABASE_URL!, {
|
||||
max: 5,
|
||||
idle_timeout: 20,
|
||||
});
|
||||
}
|
||||
|
||||
export const db = drizzle(globalForDb.pgClient, { schema });
|
||||
|
||||
Reference in New Issue
Block a user