nodejs, mongodb - How do I operate on data from multiple queries?
Posted
by
Ryan
on Stack Overflow
See other posts from Stack Overflow
or by Ryan
Published on 2011-01-10T02:47:52Z
Indexed on
2011/01/10
2:53 UTC
Read the original article
Hit count: 199
Hi all,
I'm new to JS in general, but I am trying to query some data from MongoDB. Basically, my first query retrieves information for the session with the specified session id. The second query does a simple geospacial query for documents with a location near the specified location.
I'm using the mongodb-native javascript driver. All of these query methods return their results in callbacks, so they're non-blocking. This is the root of my troubles. What I'm needing to do is retrieve the results of the second query, and create an Array of sessionIds of all the returned documents. Then I'm going to pass those to a function later. But, I can't generate this array and use it anywhere outside the callback.
Does anyone have any idea how to properly do this?
© Stack Overflow or respective owner