【发布时间】:2019-05-02 22:44:19
【问题描述】:
我想调用两个猫鼬查询“Parallel”并将两个查询的返回数据传递给客户端。
//both queries should be called parallel, not one after another
//query 1
PaperModel.find().then((papers) => {
});
//query 2
ConferenceModel.find().then((conferences) => {
});
//this function should only be called when both the
//queries have returned the data
res.render('Home', {
Papers: papers
Conferences: conferences
});
我尝试查看this,但没有搞定。谢谢
【问题讨论】:
-
就这么简单
await Promise.all([someCall(), anotherCall()]);你没得到什么?你尝试了什么?
标签: javascript node.js asynchronous mongoose es6-promise