[英]Meteor Collection not updating
對Meteor來說還很陌生,自刪除autopublish以來,我一直遇到更新我的mongoDB流星集合的錯誤。 也許我錯過了有關立即發布的一些非常關鍵的內容,但是只是在控制台中輸入:
NVC.Users.insert({name:'bob'})
--> "MTi5ePEyHyKXZFWjL"
NVC.Users.find().fetch()
--> []
因為在刪除自動發布之前我可能發誓說這行得通,所以讓我失望了。 有人可以解釋一下我所缺少的,因為我也嘗試過:
// Client
if Meteor.isClient
Deps.autorun ->
Meteor.subscribe 'rooms'
// Server
if Meteor.isServer
Meteor.startup ->
Meteor.publish 'rooms' , ->
return Rooms.find()
不要將您的訂閱放在Deps.autorun
:
if Meteor.isClient
Meteor.subscribe 'rooms'
如果您想通過Session
傳遞一個變量來更改訂閱,請使用Deps.autorun,但是在上述用例中,您不需要它。
Deps.autorun每次在其中的反應性依賴項更改時運行。 但是沒有任何內容,因此它無法運行且不預訂房間
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.