16 lines
437 B
TypeScript
16 lines
437 B
TypeScript
import { PGlite } from '@electric-sql/pglite';
|
|
import { drizzle } from 'drizzle-orm/pglite';
|
|
import * as schema from './schema.js';
|
|
import type { DbHandle } from './client.js';
|
|
|
|
export function createPgliteDb(dataDir: string): DbHandle {
|
|
const client = new PGlite(dataDir);
|
|
const db = drizzle(client, { schema });
|
|
return {
|
|
db: db as unknown as DbHandle['db'],
|
|
close: async () => {
|
|
await client.close();
|
|
},
|
|
};
|
|
}
|