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

31 lines
726 B
JavaScript

module.exports = Self => {
Self.remoteMethodCtx('removeFile', {
description: 'Removes a worker 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 workerDms = await Self.findById(id);
await models.Dms.removeFile(ctx, workerDms.dmsFk);
return workerDms.destroy();
};
};