const pg = require('../pg') const joinjs = require('join-js').default; const debug = require('debug')('sos:db:address') const mappings = require('../mappings') const address = module.exports = {} address.create = async (name, company, street1, street2, city, state, zip, country, phone, easypost_id) => { const query = { text: 'select * from sos.create_address($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)', values: [ name, company, street1, street2, city, state, zip, country, phone, easypost_id ] } debug(query) const {rows} = await pg.query(query) return joinjs.map(rows, mappings, 'addressMap', 'address_')[0] }