module.exports = Self => { Self.remoteMethodCtx('removeFile', { description: 'Removes a client document', accessType: 'WRITE', accepts: { arg: 'id', type: 'Number', description: 'The document id', http: {source: 'path'} }, returns: { type: 'Object', root: true }, http: { path: `/:id/removeFile`, verb: 'POST' } }); Self.removeFile = async(ctx, id) => { const models = Self.app.models; const clientDms = await models.ClientDms.findById(id); await models.Dms.removeFile(ctx, clientDms.dmsFk); return clientDms.destroy(); }; };