我开始大量使用本地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