Can you nest collection calls in MongoDB?
db.collection 'one', (err, on开发者_如何转开发e) ->
one.#do stuff
db.collection 'two', (err, two) ->
two.#do stuff
Yes.
This is (as far as I am aware) the simplest way of doing things in MongoDB and Node.js.
In your example one
will contain the results of the first query, and two
the results of the second.
If you are doing a lot of nested queries, where the nested query does not depend on the results of the outer query, you could consider using the Async module (or an alternative) to parallelise the query.
精彩评论