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:
parent
cb6af7b902
commit
90544a21c2
File diff suppressed because one or more lines are too long
@ -1,3 +1,3 @@
|
||||
nodeLinker: node-modules
|
||||
|
||||
yarnPath: .yarn/releases/yarn-4.5.3.cjs
|
||||
yarnPath: .yarn/releases/yarn-4.6.0.cjs
|
||||
|
@ -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"
|
||||
}
|
||||
|
@ -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
@ -1 +1 @@
|
||||
yarnPath: .yarn/releases/yarn-4.5.3.cjs
|
||||
yarnPath: .yarn/releases/yarn-4.6.0.cjs
|
||||
|
@ -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"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user