mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
24 lines
635 B
TypeScript
24 lines
635 B
TypeScript
import { PGlite } from '@electric-sql/pglite';
|
|
import { PgliteDialect } from '@soapbox/kysely-pglite';
|
|
import { Kysely } from 'kysely';
|
|
|
|
import { DittoDatabase } from '@/db/DittoDatabase.ts';
|
|
import { DittoTables } from '@/db/DittoTables.ts';
|
|
import { KyselyLogger } from '@/db/KyselyLogger.ts';
|
|
|
|
export class DittoPglite {
|
|
static create(databaseUrl: string): DittoDatabase {
|
|
const kysely = new Kysely<DittoTables>({
|
|
dialect: new PgliteDialect({
|
|
database: new PGlite(databaseUrl),
|
|
}),
|
|
log: KyselyLogger,
|
|
});
|
|
|
|
return {
|
|
kysely,
|
|
poolSize: 1,
|
|
availableConnections: 1,
|
|
};
|
|
}
|
|
}
|