module.exports = Self => { Self.remoteMethod('comboVehicles', { description: 'returns list of vehicles', accessType: 'READ', accepts: [{ arg: 'filter', type: 'Object', required: false, description: 'Filter defining where and paginated data', http: {source: 'query'} }], returns: { arg: 'data', type: 'Vehicle', root: true }, http: { path: `/comboVehicles`, verb: 'get' } }); Self.comboVehicles = (filter, callback) => { Self.find(filter, (_, instances) => { callback(null, formatOutput(instances)); }); }; function formatOutput(instances) { let results = []; for (let instance of instances) { let numberPlate = ` ${instance.numberPlate}` || ''; results.push({ id: instance.id, name: `${instance.tradeMark} ${instance.model}${numberPlate}` }); } return results; } };