我開始大量使用本地minimongo收集清除本地流星蒙戈集合
LocalItems = new Meteor.Collection null
SomeOtherItems = new Meteor.Collection null
,我希望能夠清空所有這些地方集合,當用戶註銷; 有什麼建議嗎?
我開始大量使用本地minimongo收集清除本地流星蒙戈集合
LocalItems = new Meteor.Collection null
SomeOtherItems = new Meteor.Collection null
,我希望能夠清空所有這些地方集合,當用戶註銷; 有什麼建議嗎?
試試這個,我從你的代碼中假設你正在使用coffeescript。如果沒有,讓我知道,我將它改寫爲JavaScript的:如果你使用的帳戶的用戶界面,不直接調用logout
功能
Meteor.logout ->
LocalItems.remove {}
SomeOtherItems.remove {}
,我認爲你需要做這樣的事情:
Deps.autorun ->
unless Meteor.user()
LocalItems.remove {}
SomeOtherItems.remove {}
或者你可以這樣做:
Template.loginButtons.events
"click #login-buttons-logout": ->
LocalItems.remove {}
SomeOtherItems.remove {}
出現此錯誤:未捕獲錯誤:不允許。不受信任的代碼只能通過ID刪除文件。 [403] –
您不想實際將它們從集合中刪除,只是本地副本。 – nephets
參見[這裏](http://stackoverflow.com/questions/17072350/how-can-i-clean-a-local-collection -in-流星)。 – user728291