module.exports = Self => { Self.remoteMethod('getSummary', { description: 'Returns the shelving summary', accessType: 'READ', accepts: { arg: 'code', type: 'string', required: true, description: 'The shelving code', http: {source: 'path'} }, returns: { type: 'object', root: true }, http: { path: `/:code/getSummary`, verb: 'GET' } }); Self.getSummary = async code => { let filter = { where: {code: code}, fields: [ 'code', 'parkingFk', 'priority', 'userFk', 'isRecyclable' ], include: [ { relation: 'parking' }, { relation: 'worker', scope: { fields: ['id'], include: { relation: 'user', scope: { fields: ['id', 'nickname'] } } } } ] }; return Self.app.models.Shelving.findOne(filter); }; };