mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-03 05:34:23 +01:00
Add DittoDB module for selecting a database depending on the DATABASE_URL
This commit is contained in:
17
src/db/DittoDB.ts
Normal file
17
src/db/DittoDB.ts
Normal 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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user