Add DittoDB module for selecting a database depending on the DATABASE_URL
This commit is contained in:
parent
29102d272a
commit
4085443e45
|
@ -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.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue