50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
module.exports = Self => {
|
|
Self.remoteMethod('getTravel', {
|
|
description: 'Returns the travel',
|
|
accessType: 'READ',
|
|
accepts: {
|
|
arg: 'id',
|
|
type: 'number',
|
|
required: true,
|
|
description: 'The travel id',
|
|
http: {source: 'path'}
|
|
},
|
|
returns: {
|
|
type: 'object',
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/:id/getTravel`,
|
|
verb: 'GET'
|
|
}
|
|
});
|
|
|
|
Self.getTravel = async id => {
|
|
let filter = {
|
|
where: {id: id},
|
|
include: [
|
|
{
|
|
relation: 'agency',
|
|
scope: {
|
|
fields: ['id', 'name']
|
|
}
|
|
},
|
|
{
|
|
relation: 'warehouseIn',
|
|
scope: {
|
|
fields: ['id', 'name']
|
|
}
|
|
},
|
|
{
|
|
relation: 'warehouseOut',
|
|
scope: {
|
|
fields: ['id', 'name']
|
|
}
|
|
}
|
|
],
|
|
};
|
|
|
|
return Self.app.models.Travel.findOne(filter);
|
|
};
|
|
};
|