MongoDB, Mongoose results from one Find to search another collection
<p>I know this goes against the design of MongoDB and its No-SQL model but I'm trying to lookup Documents in one collection then use the ID field from the results to lookup corresponding records in another collection. Effectively trying to emulate a join. </p>

<pre><code>//query is irrelevant to question
var results = collectionOne.find(query).limit(limit);

var a = [];

results.forEach(function(r)
{
    var aquery = { id : {$eq : r.id}};
    collectionTwo.find(aquery).limit(limit).exec(function, b)
    {
        if (err)
        {
            res.render('error',
            {
                status :  500
            });
        }
        else
        {
            a.push(b);
        }
   });
});
res.jsonp(a);
</code></pre>