UNPKG

@speakr/speakr-module-services

Version:
30 lines (26 loc) 712 B
"use strict"; const db = require('../../db'); const _ = require('lodash'); module.exports = { newRecord }; function newRecord(options) { let where = { id_hash: options.req.params.id_hash }; return db.campaigns.findOne({where}) .then((campaigns) => { if(!!campaigns) { let create = { name: options.req.body.name, email: options.req.body.email, campaign_id: campaigns.id }; return db.point_of_contacts.create(create) .then((contact) => { options.point_of_contact = contact; return Promise.resolve(options) }).catch((err) => { return Promise.reject(err); }) } }); }