You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
861 B
JavaScript
37 lines
861 B
JavaScript
5 years ago
|
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
|
||
|
})
|