salix/modules/route/back/methods/route/unlink.js

43 lines
1.1 KiB
JavaScript

module.exports = Self => {
Self.remoteMethod('unlink', {
description: 'Removes the matching entries from zoneAgencyMode',
accessType: 'WRITE',
accepts: [
{
arg: 'agencyModeId',
type: 'number',
required: true,
description: 'The agencyMode id',
},
{
arg: 'zoneId',
type: 'number',
required: true,
description: 'The zone id',
},
],
returns: {
type: ['object'],
root: true
},
http: {
path: `/unlink`,
verb: 'POST'
}
});
Self.unlink = async(agencyModeId, zoneId, options) => {
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const where = {
agencyModeFk: agencyModeId,
zoneFk: zoneId
};
await Self.app.models.ZoneAgencyMode.destroyAll(where, myOptions);
};
};