Chore: refactor to use new schema changing queries
This commit is contained in:
parent
304f792484
commit
e6059be8d2
44 changed files with 185 additions and 171 deletions
|
|
@ -16,11 +16,11 @@ function atomic (machineTx, pi) {
|
|||
const sql = 'select * from cash_in_txs where id=$1'
|
||||
const sql2 = 'select * from bills where cash_in_txs_id=$1'
|
||||
|
||||
return t.oneOrNone(sql, [machineTx.id])
|
||||
return t.$oneOrNone(sql, [machineTx.id])
|
||||
.then(row => {
|
||||
if (row && row.tx_version >= machineTx.txVersion) throw new E.StaleTxError('Stale tx')
|
||||
|
||||
return t.any(sql2, [machineTx.id])
|
||||
return t.$any(sql2, [machineTx.id])
|
||||
.then(billRows => {
|
||||
const dbTx = cashInLow.toObj(row)
|
||||
|
||||
|
|
@ -47,9 +47,9 @@ function insertNewBills (t, billRows, machineTx) {
|
|||
const sql2 = `update devices set cashbox = cashbox + $2
|
||||
where device_id = $1`
|
||||
|
||||
return t.none(sql2, [deviceID, dbBills.length])
|
||||
return t.$none(sql2, [deviceID, dbBills.length])
|
||||
.then(() => {
|
||||
return t.none(sql)
|
||||
return t.$none(sql)
|
||||
})
|
||||
.then(() => bills)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue