我今天刚刚开始使用流星,似乎无法弄清楚我做错了什么.我有一个在发布函数内运行的查询,但此查询是由另一个查询的结果过滤的.
简而言之,当我将文档添加到正在发布的数据库(CollectionTwo)时,它可以像我期望的那样工作,但是当我在用于过滤(CollectionOne)的数据库中进行更改时,流星不会表现出反应性.
CollectionOne = new Meteor.Collection("one")
CollectionTwo = new Meteor.Collection("two")
Meteor.publish("items", ->
not_hidden = CollectionOne.find().fetch()
return CollectionTwo.find( _id: {'$in':( t.my_id for t in not_hidden )} )
)
Run Code Online (Sandbox Code Playgroud)
同时,在客户端......
CollectionOne = new Meteor.Collection("one")
CollectionTwo = new Meteor.Collection("two")
Meteor.subscribe("items")
_.extend( Template.items,
items: ->
not_hidden = CollectionOne.find().fetch()
return CollectionTwo.find( _id: {'$in':( t.my_id for t in not_hidden )} )
)
Run Code Online (Sandbox Code Playgroud)
任何想法适当的解决方案可能是什么?
| 归档时间: |
|
| 查看次数: |
1029 次 |
| 最近记录: |