Add DittoDB module for selecting a database depending on the DATABASE_URL

This commit is contained in:
Alex Gleason
2024-04-19 12:21:32 -05:00
parent 29102d272a
commit 4085443e45

17
src/db/DittoDB.ts Normal file
View File

@@ -0,0 +1,17 @@
import { Conf } from '@/config.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();
default:
throw new Error('Unsupported database URL.');
}
}
}