【发布时间】:2013-12-17 07:12:28
【问题描述】:
我开始大量使用本地 minimongo 集合
LocalItems = new Meteor.Collection null
SomeOtherItems = new Meteor.Collection null
并且我希望能够在用户注销时清空所有这些本地集合; 有什么建议吗?
【问题讨论】:
-
见here。
我开始大量使用本地 minimongo 集合
LocalItems = new Meteor.Collection null
SomeOtherItems = new Meteor.Collection null
并且我希望能够在用户注销时清空所有这些本地集合; 有什么建议吗?
【问题讨论】:
试试这个,我从你的代码中假设你正在使用咖啡脚本。如果没有,请告诉我,我会将其重写为 javascript:
Meteor.logout ->
LocalItems.remove {}
SomeOtherItems.remove {}
如果你使用accounts-ui并且不直接调用logout函数,我认为你需要做这样的事情:
Deps.autorun ->
unless Meteor.user()
LocalItems.remove {}
SomeOtherItems.remove {}
或者你可以这样做:
Template.loginButtons.events
"click #login-buttons-logout": ->
LocalItems.remove {}
SomeOtherItems.remove {}
【讨论】: