module.exports = Self => { Self.remoteMethod('getDeliveryPoint', { description: 'get the deliveryPoint address', accessType: 'WRITE', accepts: { arg: 'vehicleId', type: 'number', description: 'vehicle id asigned in the route', required: true, http: {source: 'path'} }, returns: { type: 'String', root: true }, http: { path: `/:vehicleId/getDeliveryPoint` } }); Self.getDeliveryPoint = async vehicleId => { let vehicle = await Self.app.models.Vehicle.findById(vehicleId); if (!vehicle.deliveryPointFk) return; let deliveryPoint = await Self.app.models.DeliveryPoint.findById(vehicle.deliveryPointFk); return deliveryPoint.ubication; }; };