mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Add DittoDB module for selecting a database depending on the DATABASE_URL
This commit is contained in:
parent
29102d272a
commit
4085443e45
1 changed files with 17 additions and 0 deletions
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue