chore: initial commit - CloudSearch v0.0.2

This commit is contained in:
2026-05-15 05:50:50 +08:00
commit d83225d736
102 changed files with 37926 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import { getDb } from '../database/database';
import { localTimestamp } from '../utils/time';
export interface SystemConfigEntry {
key: string;
value: string;
description?: string;
updated_at?: string;
}
export function getAllSystemConfigs(): SystemConfigEntry[] {
const db = getDb();
return db.prepare('SELECT key, value, description, updated_at FROM system_configs ORDER BY key').all() as SystemConfigEntry[];
}
export function getSystemConfig(key: string): string | null {
const db = getDb();
const row = db.prepare('SELECT value FROM system_configs WHERE key = ?').get(key) as { value: string } | undefined;
return row?.value ?? null;
}
export function updateSystemConfig(key: string, value: string): void {
const db = getDb();
db.prepare(
"UPDATE system_configs SET value = ?, updated_at = ? WHERE key = ?"
).run(value, localTimestamp(), key);
}
export function updateSystemConfigs(entries: { key: string; value: string }[]): void {
const db = getDb();
const update = db.prepare(
"UPDATE system_configs SET value = ?, updated_at = ? WHERE key = ?"
);
const tx = db.transaction((items: { key: string; value: string }[]) => {
for (const item of items) {
update.run(item.value, localTimestamp(), item.key);
}
});
tx(entries);
}