@speakr/speakr-module-services
Version:
SPEAKR Shared Service Module
24 lines (22 loc) • 633 B
JavaScript
;
const db = require('../../db');
module.exports = {
byId: byId
};
function byId(options) {
const id = options.req.params.id;
const where = { id };
return db.reports_engagements.destroy({
where
})
.then(engagement => {
if(!engagement) throw new Error(`Err deleting/already deleted engagement ID :: ${id}`)
options.engagement = engagement;
return options;
})
.catch(err => Promise.reject({
code: 409,
message: 'Could not delete Engagement',
purpose: err.message
}))
}