module.exports = Self => { Self.remoteMethod('removeChild', { description: 'Removes a child department', 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(); }; };