31 lines
733 B
JavaScript
31 lines
733 B
JavaScript
module.exports = Self => {
|
|
Self.remoteMethodCtx('removeFile', {
|
|
description: 'Removes a worker document',
|
|
accessType: 'WRITE',
|
|
accepts: {
|
|
arg: 'id',
|
|
type: 'Number',
|
|
description: 'The worker 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();
|
|
};
|
|
};
|
|
|