.findOne 在 Iron Router Route 的数据属性中工作,但 .find 不能
.findOne works in data attribute of Iron Router Route but .find does not?
我正在编写一个具有动态内容加载的应用程序。我正在使用铁路由器,如果可能的话,我的目标是避免会话。我在下面写了以下路线:
Router.route('/:publisher',{
name: "publisher",
action: function(){
this.render("Publisher")
},
data: function(){
return Comics.findOne({publisher: this.params.publisher});
}
});
这有效,因为它使用 .findOne。如果我将 .findOne 切换到 .find,则不会加载任何内容,但没有错误。任何帮助,不胜感激。谢谢
注意:我看了这个链接,但遗憾的是这不是同一个问题:findOne 有效,但不能全部获取/查找
使用 collection.find().fetch()
而不是 collection.find()
collection.findOne()
大致相当于collection.find({},{limit: 1}).fetch()[0]
解释
collection.find()
是游标,而collection.find().fetch()
是对象数组。
相关文章:
- Javascript:selenium Web驱动程序isDisplayed()不工作
- jQuery UI自动完成突然停止工作
- $(this.el).find()在事件处理程序中工作,而不是在初始化函数(主干.js)中工作
- 从HTML代码段创建节点列表后,.find()未按预期工作
- .findOne 在 Iron Router Route 的数据属性中工作,但 .find 不能
- jQuery .each()、.find() 和 .append() 只在最后一个节点上工作
- jQuery .find 无法正常工作
- .find不't在jquery 1.4.2中工作,我可以'我不知道如何支持它
- .find("tagname")空结果(偶尔在Chrome中工作)
- jQuery find/each脚本不工作
- 这个Array.prototype.find()是如何工作的?
- Phonegap navigator.contacts.find不能工作
- Jquery .find()在ipad上不能正常工作
- jQuery多属性选择器find()不工作
- 为什么this.find()不能在我的插件中工作?
- 微软AJAX jscript $find不工作的隐藏/不可见的元素
- jQuery find()方法不能只在一个类上工作
- Zepto's clone()函数不能正常工作或不能将clone()与find()结合使用
- $find不在firefox中工作.ASP.NET幻灯片放映扩展器
- node.js:Mongodb.collection.find()在collection.insert工作时不工作