Collections 此.removed(集合,id)会引发异常
我试图在文档从集合中删除时通知订阅者。调用observeChanges的removed函数时,我使用此.removed(collection,id):Collections 此.removed(集合,id)会引发异常,collections,meteor,publish,Collections,Meteor,Publish,我试图在文档从集合中删除时通知订阅者。调用observeChanges的removed函数时,我使用此.removed(collection,id): Meteor.publish('tasks_listsPub', function(sUrl){ ... var self = this; ocTasksLists.find().observeChanges({ added: function (sId, oFields) { co
Meteor.publish('tasks_listsPub', function(sUrl){
...
var self = this;
ocTasksLists.find().observeChanges({
added: function (sId, oFields) {
console.log('added:'+sId);
self.added('tasks_lists', sId, oFields);
},
removed: function (sId) {
console.log('removed:'+sId);
self.removed('tasks_lists', sId); //throws a exception but sometimes it works in the browser
},
changed: function(sId, oFields){
console.log('changed:'+sId);
self.changed('tasks_lists', sId, oFields);
}
});
var cVisibleTasksLists = ocTasksLists.find({_id: {$in: oWs.tasks_lists}});
return cVisibleTasksLists;
});
问题是服务器引发异常:
removed:K8BBys7WRH4tTQRBg
Exception in queued task: Error: Removed nonexistent document K8BBys7WRH4tTQRBg
at _.extend.removed (app/packages/livedata/livedata_server.js:181:17)
其他浏览器有时不会删除已删除的文档。有解决办法吗?Thx您似乎在一个发布功能中发布了两个冲突的数据集 observeChanges中的self.added、self.remove和self.change函数试图使用OctasksList中的所有内容更新客户端
返回CVisibleTasksList但是,code>正在尝试仅发布与您的查询匹配的OctasksList的子集
这些相互冲突的发布指令有时会导致客户机无法从OctasksList中删除所有文档,从而导致错误消息
无论您想要整个数据集还是子集,都可以像在最后两行中一样返回数据库游标。删除observeChanges函数以及.added、.removed和.changed函数将修复您的错误