2019-08-31 04:07:25 +05:00
|
|
|
const Errors = {
|
|
|
|
PROJECT_MEMBERSHIP_NOT_FOUND: {
|
|
|
|
notFound: 'Project membership is not found'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
inputs: {
|
|
|
|
id: {
|
2019-10-10 02:51:54 +05:00
|
|
|
type: 'string',
|
|
|
|
regex: /^[0-9]+$/,
|
2019-08-31 04:07:25 +05:00
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
exits: {
|
|
|
|
notFound: {
|
|
|
|
responseType: 'notFound'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
fn: async function(inputs, exits) {
|
|
|
|
let projectMembership = await ProjectMembership.findOne(inputs.id);
|
|
|
|
|
|
|
|
if (!projectMembership) {
|
|
|
|
throw Errors.PROJECT_MEMBERSHIP_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
projectMembership = await sails.helpers.deleteProjectMembership(
|
|
|
|
projectMembership,
|
|
|
|
this.req
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!projectMembership) {
|
|
|
|
throw Errors.PROJECT_MEMBERSHIP_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
return exits.success({
|
|
|
|
item: projectMembership
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|