salix/services/loopback/common/methods/sale/price-gap.js

52 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-04-10 05:48:04 +00:00
module.exports = Self => {
Self.remoteMethod('priceGap', {
description: 'Returns a sale price gap',
accessType: 'READ',
accepts: [{
arg: 'ticketFk',
type: 'number',
required: true,
description: 'ticket id',
http: {source: 'path'}
}],
returns: {
type: ['Object'],
root: true
},
http: {
path: `/:ticketFk/priceGap`,
verb: 'GET'
}
});
Self.priceGap = async ticketFk => {
let filter = {
where: {
ticketFk: ticketFk
},
order: 'concept ASC',
include: [{
relation: 'item',
scope: {
include: {
relation: 'tags',
2018-04-10 05:48:04 +00:00
scope: {
fields: ['tagFk', 'value'],
include: {
relation: 'tag',
scope: {
fields: ['name']
}
},
limit: 6
}
},
fields: ['itemFk', 'name']
}
}]
};
return await Self.find(filter);
};
};