feat: settings queries

This commit is contained in:
2026-05-20 17:41:45 +02:00
parent f76d6456ab
commit c7e46196ca
2 changed files with 48 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
import type { Database } from 'better-sqlite3';
export function getSetting(db: Database, key: string): string | null {
const row = db.prepare('SELECT value FROM settings WHERE key = ?').get(key) as { value: string } | undefined;
return row?.value ?? null;
}
export function setSetting(db: Database, key: string, value: string): void {
db.prepare('INSERT OR REPLACE INTO settings (key, value) VALUES (?, ?)').run(key, value);
}
export function getAllSettings(db: Database): Record<string, string> {
const rows = db.prepare('SELECT key, value FROM settings').all() as Array<{ key: string; value: string }>;
return Object.fromEntries(rows.map(r => [r.key, r.value]));
}