salix/modules/client/back/methods/client-dms/removeFile.js

31 lines
726 B
JavaScript
Raw Normal View History

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;
2019-11-22 12:46:38 +00:00
const clientDms = await Self.findById(id);
await models.Dms.removeFile(ctx, clientDms.dmsFk);
return clientDms.destroy();
};
};