LGTM
This commit is contained in:
@@ -33,6 +33,14 @@ export function initDatabase() {
|
||||
)
|
||||
`);
|
||||
|
||||
// Create settings table for custom AUEC amount
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS settings (
|
||||
key TEXT PRIMARY KEY,
|
||||
value TEXT NOT NULL
|
||||
)
|
||||
`);
|
||||
|
||||
console.log('Database initialized at:', dbPath);
|
||||
}
|
||||
|
||||
@@ -80,6 +88,26 @@ export function deleteAlert(id: string): void {
|
||||
stmt.run(id);
|
||||
}
|
||||
|
||||
export function getCustomAuecAmount(): number | null {
|
||||
if (!db) throw new Error('Database not initialized');
|
||||
|
||||
const stmt = db.prepare('SELECT value FROM settings WHERE key = ?');
|
||||
const row = stmt.get('customAuecAmount') as any;
|
||||
|
||||
return row ? parseFloat(row.value) : null;
|
||||
}
|
||||
|
||||
export function setCustomAuecAmount(amount: number): void {
|
||||
if (!db) throw new Error('Database not initialized');
|
||||
|
||||
const stmt = db.prepare(`
|
||||
INSERT OR REPLACE INTO settings (key, value)
|
||||
VALUES (?, ?)
|
||||
`);
|
||||
|
||||
stmt.run('customAuecAmount', amount.toString());
|
||||
}
|
||||
|
||||
export function closeDatabase(): void {
|
||||
if (db) {
|
||||
db.close();
|
||||
|
||||
Reference in New Issue
Block a user