Here is the none working format, this is in a function that should return results when db is finished.
var results = []; dependencies.forEach(function(dependency) { db.collection('parts_relations').find(query).toArray(function(err, relations) { relations.forEach(function(relation) { results.push(relation); }); }); }); I have tried two things without success: (this returns before finishing) var results = []; var counter = 0; dependencies.forEach(function(dependency) { counter++; db.collection('parts_relations').find(query).toArray(function(err, relations) { relations.forEach(function(relation) { results.push(relation); }); if (counter >= dependencies.length) { return results; } }); }); I also tried wrapping db.collection in a function and passing it to async.parallel without luck. Any suggestions? -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en