format for latest standard

This commit is contained in:
Josh Harvey 2018-03-10 18:59:40 +00:00
parent 4108efd9c7
commit c2af183911
77 changed files with 1697 additions and 1693 deletions

View file

@ -15,8 +15,8 @@ module.exports = {toObj, upsert, insert, update, massage, isClearToSend}
function convertBigNumFields (obj) {
const convert = value => value && value.isBigNumber
? value.toString()
: value
? value.toString()
: value
return _.mapValues(convert, obj)
}
@ -45,18 +45,18 @@ function toObj (row) {
function upsert (t, dbTx, preProcessedTx) {
if (!dbTx) {
return insert(t, preProcessedTx)
.then(tx => ({dbTx, tx}))
.then(tx => ({dbTx, tx}))
}
return update(t, dbTx, diff(dbTx, preProcessedTx))
.then(tx => ({dbTx, tx}))
.then(tx => ({dbTx, tx}))
}
function insert (t, tx) {
const dbTx = massage(tx)
const sql = pgp.helpers.insert(dbTx, null, 'cash_in_txs') + ' returning *'
return t.one(sql)
.then(toObj)
.then(toObj)
}
function update (t, tx, changes) {
@ -67,7 +67,7 @@ function update (t, tx, changes) {
pgp.as.format(' where id=$1', [tx.id]) + ' returning *'
return t.one(sql)
.then(toObj)
.then(toObj)
}
function diff (oldTx, newTx) {