const pg = require('../pg') const joinjs = require('join-js').default; const debug = require('debug')('sos:db:category') const mappings = require('../mappings') const dbUtil = require('../util') const shipment = module.exports = {} shipment.findAll = () => dbUtil.executeQuery({ query: 'select * from sos.v_shipment', returnType: 'shipment', single: false }) shipment.findByUUID = uuid => dbUtil.executeQuery({ query: { text: 'select * from sos.v_shipment where shipment_uuid = $1', values: [uuid] }, returnType: 'shipment', single: true }) shipment.createShipment = (description, items) => dbUtil.executeFunction({ name: 'create_shipment', params: [ description, items.map(item => item.uuid), items.map(item => item.count) ], returnType: 'shipment', single: true })