mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-18 21:41:23 +02:00
- mana-sync on port 3051 (Go sync server for local-first apps) - mana-notify-go on port 3040 (Go notification service) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
15 lines
406 B
TypeScript
15 lines
406 B
TypeScript
import { drizzle } from 'drizzle-orm/postgres-js';
|
|
import postgres from 'postgres';
|
|
import * as schema from './schema/index';
|
|
|
|
let db: ReturnType<typeof drizzle<typeof schema>> | null = null;
|
|
|
|
export function getDb(databaseUrl: string) {
|
|
if (!db) {
|
|
const client = postgres(databaseUrl, { max: 10 });
|
|
db = drizzle(client, { schema });
|
|
}
|
|
return db;
|
|
}
|
|
|
|
export type Database = ReturnType<typeof getDb>;
|