Download src/server/db/client.ts from bhyve/auto-lms: direct link, hf CLI and curl.
- Browser
- Download file 548 Bytes
-
https://huggingface.co/spaces/bhyve/auto-lms/resolve/main/src/server/db/client.ts
- Command line
-
hf download hf://spaces/bhyve/auto-lms/src/server/db/client.ts
-
curl -L -o client.ts https://huggingface.co/spaces/bhyve/auto-lms/resolve/main/src/server/db/client.ts
548 Bytes
| import { Pool } from 'pg'; | |
| import { drizzle } from 'drizzle-orm/node-postgres'; | |
| import * as schema from './schema'; | |
| // Reuse a single pool across Next.js HMR reloads and within the worker process. | |
| const globalForDb = globalThis as unknown as { __autoLmsPool?: Pool }; | |
| export const pool = | |
| globalForDb.__autoLmsPool ?? | |
| new Pool({ | |
| connectionString: process.env.DATABASE_URL, | |
| max: 10, | |
| }); | |
| if (!globalForDb.__autoLmsPool) { | |
| globalForDb.__autoLmsPool = pool; | |
| } | |
| export const db = drizzle(pool, { schema }); | |
| export type Db = typeof db; | |