开发者

Can you nest collection calls? MongoDB

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜