This commit is contained in:
2023-11-26 07:21:24 +07:00
parent 9112c1c24a
commit 7759851541
8 changed files with 23 additions and 22 deletions

View File

@@ -451,7 +451,7 @@ export class LumeStorage {
}
public async createSetting(key: string, value: string) {
const currentSetting = await this.getSettingValue(key);
const currentSetting = await this.checkSettingValue(key);
if (!currentSetting)
return await this.db.execute(
@@ -475,6 +475,15 @@ export class LumeStorage {
return results;
}
public async checkSettingValue(key: string) {
const results: { key: string; value: string }[] = await this.db.select(
'SELECT * FROM settings WHERE key = $1 ORDER BY id DESC LIMIT 1;',
[key]
);
if (!results.length) return false;
return results[0].value;
}
public async getSettingValue(key: string) {
const results: { key: string; value: string }[] = await this.db.select(
'SELECT * FROM settings WHERE key = $1 ORDER BY id DESC LIMIT 1;',