1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01:00

fix: after discussion, insert is now an upsert

This commit is contained in:
Christopher Kolstad 2025-01-28 11:34:35 +01:00
parent cb6af7b902
commit 90544a21c2
No known key found for this signature in database
GPG Key ID: D9041DC670F032F3
7 changed files with 581 additions and 589 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,3 @@
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-4.5.3.cjs
yarnPath: .yarn/releases/yarn-4.6.0.cjs

View File

@ -155,7 +155,7 @@
"last 1 safari version"
]
},
"packageManager": "yarn@4.5.3",
"packageManager": "yarn@4.6.0",
"dependencies": {
"json-2-csv": "^5.5.5"
}

View File

@ -32,13 +32,6 @@ export default class SettingStore implements ISettingStore {
});
}
async insertNewRow(name: string, content: any) {
return this.db(TABLE)
.insert({ name, content })
.onConflict('name')
.merge();
}
async exists(name: string): Promise<boolean> {
const result = await this.db.raw(
`SELECT EXISTS (SELECT 1 FROM ${TABLE} WHERE name = ?) AS present`,
@ -61,13 +54,12 @@ export default class SettingStore implements ISettingStore {
return undefined;
}
// Is actually an upsert
async insert(name: string, content: any): Promise<void> {
const exists = await this.exists(name);
if (exists) {
await this.updateRow(name, content);
} else {
await this.insertNewRow(name, content);
}
await this.db(TABLE)
.insert({ name, content })
.onConflict('name')
.merge();
}
async delete(name: string): Promise<void> {

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
yarnPath: .yarn/releases/yarn-4.5.3.cjs
yarnPath: .yarn/releases/yarn-4.6.0.cjs

View File

@ -59,5 +59,5 @@
"http-proxy-middleware": "3.0.3",
"express/path-to-regexp": "0.1.12"
},
"packageManager": "yarn@4.5.3"
"packageManager": "yarn@4.6.0"
}