Provide all customer info in customers.get

This commit is contained in:
goga-m 2017-10-03 20:58:18 +03:00 committed by Josh Harvey
parent f237214219
commit 168cc038a3

View file

@ -17,12 +17,13 @@ function add (customer) {
}
function get (phone) {
const sql = 'select id, phone from customers where phone=$1'
const sql = 'select * from customers where phone=$1'
return db.oneOrNone(sql, [phone])
.then(customer => {
if (!customer) return
return getDailyVolume(customer.id).then(dailyVolume => {
return _.set('dailyVolume', dailyVolume, customer)
const formatted = camelize(customer)
return _.set('dailyVolume', dailyVolume, formatted)
})
})
}