🎉 init
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { createClient } from '@libsql/client'
|
||||
import { drizzle } from 'drizzle-orm/libsql'
|
||||
import * as schema from './schema'
|
||||
|
||||
let instance: ReturnType<typeof drizzle<typeof schema>> | undefined
|
||||
|
||||
export function useDb() {
|
||||
if (!instance) {
|
||||
const config = useRuntimeConfig()
|
||||
const client = createClient({
|
||||
url: config.databaseUrl,
|
||||
authToken: config.databaseAuthToken || undefined,
|
||||
})
|
||||
instance = drizzle(client, { schema })
|
||||
}
|
||||
return instance
|
||||
}
|
||||
Reference in New Issue
Block a user