Skip to content
Source
Sign inSign up
fuko/trytanstackdb.com
Open History to see the last commit

index.ts

17 lines425 Bytes

1import { PGlite } from "@electric-sql/pglite";
2import { drizzle } from "drizzle-orm/pglite";
3​
4const dbName = import.meta.env.DEV
5 ? "idb://DEV-trytanstackdb"
6 : "idb://trytanstackdb";
7​
8/** The name of the IndexedDB database used by PGlite */
9export const idbName = `/pglite/${dbName.replace("idb://", "")}`;
10​
11export const client = new PGlite(dbName);
12​
13export const db = drizzle({
14 client,
15});
16​
17export type DB = typeof db;