I have the following structure: Volunteers VolunteerTrips Trips
Volunteer links to VolunteerTrips via volunteerId. Trips links to VolunteerTrips via tripId. I have the relations set up so I can get the trips list from volunteers and vice versa. What I'd like now is a remote method that concatenates those trips into a list.
For example, /Volunteers/tripList with a value of 1 (volunteerId) would return "belize peru". So the remote method would call /Volunteers/1/trips, loop through that list, and build a string of the tripName property then return it.
Looking at the documentation I see adding to volunteers.js something like this:
module.exports = function(Volunteers) {
Volunteers.tripList = function(volunteerId, cb) {
cb(null, "belize madagascar");
}
Volunteers.remoteMethod(
'tripList',
{
accepts: {arg: 'volunteerId', type: 'string'},
returns: {arg: 'tripList', type: 'string'}
}
);
};
However, I'm stuck at how to make an additional call to get the trips, then loop through and build my string. Can someone help me?