Files
splitt-the-bill/server/database/client.ts
T
anbraten 99a9f908f1
tinyedge/deploy Deployed by TinyEdge
move tabs into own pages
2026-08-07 15:49:43 +02:00

19 lines
539 B
TypeScript

import { createClient } from '@libsql/client';
import { drizzle } from 'drizzle-orm/libsql';
import * as schema from './schema';
import type { H3Event } from 'h3';
let instance: ReturnType<typeof drizzle<typeof schema>> | undefined;
export function useDb(event?: H3Event) {
if (!instance) {
const config = useRuntimeConfig(event);
const client = createClient({
url: config.database.url,
authToken: config.database.authToken || undefined,
});
instance = drizzle(client, { schema });
}
return instance;
}