modified version
This commit is contained in:
@@ -99,53 +99,3 @@ export async function getExportProfile() {
|
||||
|
||||
return rows.length ? rows[0] : null;
|
||||
}
|
||||
|
||||
export async function getAppConfig() {
|
||||
/*
|
||||
* Config values are stored as JSON so the frontend can receive structured data
|
||||
* without a separate table for every small setting. The helper converts JSON
|
||||
* strings into usable objects and arrays before returning them.
|
||||
*/
|
||||
const rows = await query(
|
||||
`
|
||||
SELECT
|
||||
config_key AS configKey,
|
||||
config_value_json AS configValue
|
||||
FROM app_config
|
||||
ORDER BY config_key ASC
|
||||
`
|
||||
);
|
||||
|
||||
return rows.map((row) => ({
|
||||
key: row.configKey,
|
||||
value: parseJsonColumn(row.configValue)
|
||||
}));
|
||||
}
|
||||
|
||||
export async function getAppConfigValue(key) {
|
||||
const rows = await query(
|
||||
`SELECT config_value_json AS configValue FROM app_config WHERE config_key = ? LIMIT 1`,
|
||||
[key]
|
||||
);
|
||||
|
||||
return rows.length ? parseJsonColumn(rows[0].configValue) : null;
|
||||
}
|
||||
|
||||
export async function upsertAppConfig(key, value) {
|
||||
/*
|
||||
* Upsert a single app_config row. Used by the admin module to persist entity
|
||||
* data (users, sites, CL records, etc.) that was previously localStorage-only.
|
||||
*/
|
||||
await query(
|
||||
`
|
||||
INSERT INTO app_config (config_key, config_value_json)
|
||||
VALUES (?, ?)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
config_value_json = VALUES(config_value_json),
|
||||
updated_at = NOW()
|
||||
`,
|
||||
[key, JSON.stringify(value)]
|
||||
);
|
||||
|
||||
return { key, value };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user