在一个结果页面上显示多个Mongoose模型

时间:2016-06-20 12:39:52

标签: node.js mongodb

我需要在一个结果页面上显示多个Mongoose模型。这是我当前获取结果页面的代码。我为" Cards"设置了模型。和#34;信仰"但我无法弄清楚两者的语法。有什么想法吗?谢谢!

app.get("/profile", function(req, res){
    Cards.find({ "author.username": req.user.username }, function(err, author){
    Beliefs.find({"author.username": req.user.username }, function(err, author){
    if (err){
    console.log(err);
     } else { 
res.render("done.ejs", {Beliefs: author, Cards: author, currentUser: req.user});
}
});
});
});

1 个答案:

答案 0 :(得分:1)

尝试为作者使用不同的变量名称。 Belief的回调函数参数author与您从author模型收到的Cards重叠。像believesAuthor和cardsAuthor这样的东西应该做。

相关问题