@speakr/speakr-module-services
Version:
SPEAKR Shared Service Module
46 lines (37 loc) • 1.01 kB
JavaScript
;
const db = require('../../db');
module.exports = {
byId,
byIdHash
};
function byId(options) {
let where = {
id: options.req.params.id
};
return db.point_of_contacts.findOne({where})
.then((point_of_contact) => {
options.point_of_contact = point_of_contact;
return db.point_of_contacts.destroy({where})
.then(() => {
return Promise.resolve(options)
})
})
.catch((err) => {
return Promise.reject(err)
});
}
function byIdHash(options) {
let where = {
id_hash: options.req.params.id_hash
};
return db.point_of_contacts.destroy({where})
.then((point_of_contacts) => {
return db.point_of_contacts.findOne({where})
.then((point_of_contact) => {
options.point_of_contact = point_of_contact;
return Promise.resolve(options)
});
}).catch((err) => {
return Promise.reject(err)
});
}