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 })]
|
['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) {
|
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')])
|
return Promise.all([loadAccounts(), getOperatorId('middleware')])
|
||||||
.then(([currentAccounts, operatorId]) => {
|
.then(([currentAccounts, operatorId]) => {
|
||||||
const newAccounts = _.merge(currentAccounts, accounts)
|
const newAccounts = _.merge(currentAccounts, accounts)
|
||||||
|
|
@ -80,10 +80,10 @@ function saveAccounts (accounts) {
|
||||||
newAccounts.elliptic.enabled = false
|
newAccounts.elliptic.enabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
return db.tx(t => {
|
return db.tx(t =>
|
||||||
return t.none(accountsSql, ['accounts', { accounts: newAccounts }, true, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
|
t.none(accountsSql, [{ accounts: newAccounts }, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
|
||||||
.then(() => notifyReload(t, operatorId))
|
.then(() => notifyReload(t, operatorId))
|
||||||
}).catch(console.error)
|
).catch(console.error)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue