arjunmehta / node-georedis

Super fast geo queries.
MIT License
192 stars 33 forks source link

how to send response from different sets? #12

Closed rakesh-ideal closed 8 years ago

rakesh-ideal commented 8 years ago

Thanks for providing nice package,

`// will find all PEOPLE ~5000m from the passed in coordinate people.nearby({latitude: 43.646838, longitude: -79.403723}, 5000, function(err, people){ if(err) console.error(err) else console.log('people nearby:', people) })

// will find all PLACES ~5000m from the passed in coordinate places.nearby({latitude: 43.646838, longitude: -79.403723}, 5000, function(err, places){ if(err) console.error(err) else console.log('places nearby:', places) })`

Is it possible to merge result from two sets (people and places) and then send as a single result? something like this -

`// will find all PEOPLE ~5000m from the passed in coordinate people.nearby({latitude: 43.646838, longitude: -79.403723}, 5000, function(err, people){ if(err) console.error(err) else result['b'] = people })

// will find all PLACES ~5000m from the passed in coordinate places.nearby({latitude: 43.646838, longitude: -79.403723}, 5000, function(err, places){ if(err) console.error(err) else result['a'] = places }) And then return res.send(result)` Please help me, I've asked this question at stack overflow but didn't get any answer http://stackoverflow.com/questions/38238402/how-to-send-multiple-objects-using-nodejs-and-georedis

sachinvrg commented 8 years ago

I've similar issue, any help would be really appreciated.

arjunmehta commented 8 years ago

@sachinvrg @rakesh-ideal

Seems like you are asking questions about how to program asynchronous code in general and combine results.

You may want to look into async. Here is a related stackoverflow answer to the problem