Feat: upgrade pg-promise and fix breaking changes

This commit is contained in:
csrapr 2021-02-26 18:41:53 +00:00 committed by Josh Harvey
parent c4ea21259a
commit 8cd1389de3
7 changed files with 79 additions and 83 deletions

View file

@ -5,13 +5,9 @@ const E = require('../error')
const cashInLow = require('./cash-in-low')
module.exports = {atomic}
module.exports = { atomic }
function atomic (machineTx, pi) {
const TransactionMode = pgp.txMode.TransactionMode
const isolationLevel = pgp.txMode.isolationLevel
const tmSRD = new TransactionMode({tiLevel: isolationLevel.serializable})
function transaction (t) {
const sql = 'select * from cash_in_txs where id=$1'
const sql2 = 'select * from bills where cash_in_txs_id=$1'
@ -33,9 +29,6 @@ function atomic (machineTx, pi) {
})
})
}
transaction.txMode = tmSRD
return transaction
}

View file

@ -19,7 +19,11 @@ const MAX_PENDING = 10
module.exports = { post, monitorPending, cancel, PENDING_INTERVAL }
function post (machineTx, pi) {
return db.tx(cashInAtomic.atomic(machineTx, pi))
const TransactionMode = pgp.txMode.TransactionMode
const isolationLevel = pgp.txMode.isolationLevel
const mode = new TransactionMode({ tiLevel: isolationLevel.serializable })
return db.tx({ mode }, cashInAtomic.atomic(machineTx, pi))
.then(r => {
const updatedTx = r.tx
let blacklisted = false