refactor: inline query parameters
This commit is contained in:
parent
cac88fda45
commit
d3d4042d97
1 changed files with 7 additions and 7 deletions
|
|
@ -62,11 +62,11 @@ const notifyReload = (dbOrTx, operatorId) =>
|
|||
['reload', JSON.stringify({ schema: asyncLocalStorage.getStore().get('schema'), operatorId })]
|
||||
)
|
||||
|
||||
const accountsSql = `UPDATE user_config SET data = $2, valid = $3, schema_version = $4 WHERE type = $1;
|
||||
INSERT INTO user_config (type, data, valid, schema_version)
|
||||
SELECT $1, $2, $3, $4 WHERE $1 NOT IN (SELECT type FROM user_config)`
|
||||
|
||||
function saveAccounts (accounts) {
|
||||
const accountsSql = `UPDATE user_config SET data = $1, valid = TRUE, schema_version = $2 WHERE type = 'accounts';
|
||||
INSERT INTO user_config (type, data, valid, schema_version)
|
||||
SELECT 'accounts', $1, TRUE, $2 WHERE 'accounts' NOT IN (SELECT type FROM user_config)`
|
||||
|
||||
return Promise.all([loadAccounts(), getOperatorId('middleware')])
|
||||
.then(([currentAccounts, operatorId]) => {
|
||||
const newAccounts = _.merge(currentAccounts, accounts)
|
||||
|
|
@ -80,10 +80,10 @@ function saveAccounts (accounts) {
|
|||
newAccounts.elliptic.enabled = false
|
||||
}
|
||||
|
||||
return db.tx(t => {
|
||||
return t.none(accountsSql, ['accounts', { accounts: newAccounts }, true, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
|
||||
return db.tx(t =>
|
||||
t.none(accountsSql, [{ accounts: newAccounts }, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
|
||||
.then(() => notifyReload(t, operatorId))
|
||||
}).catch(console.error)
|
||||
).catch(console.error)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue