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.

31 lines
721 B
JavaScript

const pg = require('../pg')
const joinjs = require('join-js').default;
const debug = require('debug')('sos:db:order')
const mappings = require('../mappings')
const order = module.exports = {}
order.create = async function(cart_uuid){
const query = {
text: 'select * from sos.create_order($1)',
values: [cart_uuid]
}
debug(query);
const {rows} = await pg.query(query)
return joinjs.map(rows, mappings, 'orderMap', 'order_')[0];
}
order.findForCart = async function(cart_uuid) {
const query = {
text: 'select * from sos.find_order_for_cart($1)',
values: [cart_uuid]
}
debug(query)
const {rows} = await pg.query(query)
return joinjs.map(rows, mappings, 'orderMap', 'order_')[0];
}