【发布时间】:2011-09-05 01:42:57
【问题描述】:
我能找到的所有内容都可以用来渲染带有猫鼬结果的页面:
users.find({}, function(err, docs){
res.render('profile/profile', {
users: docs
});
});
我怎样才能从查询中返回结果,更像这样?
var a_users = users.find({}); //non-working example
这样我就可以在页面上发布多个结果?
喜欢:
/* non working example */
var a_users = users.find({});
var a_articles = articles.find({});
res.render('profile/profile', {
users: a_users
, articles: a_articles
});
这个可以吗?
【问题讨论】:
-
当ES7 rolls around时你的梦想就会实现。
-
你应该看看deasync,所以函数看起来是同步执行的。
-
为了更好地理解这个问题及其解决方案,请参考stackoverflow.com/questions/14220321/…
标签: mongodb node.js express mongoose