fix: query result formatting

This commit is contained in:
Sérgio Salgado 2021-04-13 13:35:33 +01:00 committed by Josh Harvey
parent d6d8280a36
commit a79a5a21e7

View file

@ -19,15 +19,7 @@ function createCashboxBatch (rec) {
function getBatches () {
const sql = `SELECT cb.id, cb.device_id, cb.created, cb.operation_type, cb.bill_count_override, cb.performed_by,
json_agg(b.*) AS bills FROM cashbox_batches cb LEFT JOIN bills b ON cb.id=b.cashbox_batch_id GROUP BY cb.id`
return db.any(sql).then(res => _.map(it => ({
id: it.id,
deviceId: it.device_id,
created: it.created,
operationType: it.operation_type,
billCountOverride: it.bill_count_override,
performedBy: it.performed_by,
bills: it.bills
}), res))
return db.any(sql).then(res => _.map(it => _.mapKeys(ite => _.camelCase(ite), it), res))
}
function editBatchById (id, performedBy) {