mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-03 13:44:24 +01:00
22 lines
636 B
TypeScript
22 lines
636 B
TypeScript
import { Conf } from '@/config.ts';
|
|
import { DittoPostgres } from '@/db/adapters/DittoPostgres.ts';
|
|
import { DittoSQLite } from '@/db/adapters/DittoSQLite.ts';
|
|
import { DittoTables } from '@/db/DittoTables.ts';
|
|
import { Kysely } from '@/deps.ts';
|
|
|
|
export class DittoDB {
|
|
static getInstance(): Promise<Kysely<DittoTables>> {
|
|
const { databaseUrl } = Conf;
|
|
|
|
switch (databaseUrl.protocol) {
|
|
case 'sqlite:':
|
|
return DittoSQLite.getInstance();
|
|
case 'postgres:':
|
|
case 'postgresql:':
|
|
return DittoPostgres.getInstance();
|
|
default:
|
|
throw new Error('Unsupported database URL.');
|
|
}
|
|
}
|
|
}
|