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.
21 lines
644 B
JavaScript
21 lines
644 B
JavaScript
5 years ago
|
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]
|
||
|
}
|