2019-10-04 05:41:24 +00:00
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethod('removeChild', {
|
2019-10-08 10:48:12 +00:00
|
|
|
description: 'Removes a child department',
|
2019-10-04 05:41:24 +00:00
|
|
|
accessType: 'WRITE',
|
|
|
|
accepts: [{
|
|
|
|
arg: 'id',
|
|
|
|
type: 'Number',
|
|
|
|
description: 'The department id',
|
|
|
|
http: {source: 'path'}
|
|
|
|
}],
|
|
|
|
returns: {
|
|
|
|
type: 'Object',
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
|
|
|
path: `/:id/removeChild`,
|
|
|
|
verb: 'POST'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Self.removeChild = async id => {
|
|
|
|
const models = Self.app.models;
|
|
|
|
const department = await models.Department.findById(id);
|
|
|
|
|
|
|
|
return await department.destroy();
|
|
|
|
};
|
|
|
|
};
|