考虑这段代码:
Meteor.publish("Children", function (id) {
// Find all the items that are children of an item that I am sharing
//
var sharing = Items.find({$and : [{_id:id},{sharing:{$elemMatch: {user_id:this.userId}}}]}).fetch();
var shared_children = [];
sharing.forEach(function(share){
share.children.forEach(function(child){
shared_children.push(child.id);
});
});
return Items.find({_id:{$in : shared_children}});
});
在我的 Meteor.publish 中,我动态生成一个 id 数组以在我的.find
. 它适用于手动查询数据,但是当我向“共享”字段添加新元素时,只有我添加该字段的客户端显示更新。查看相同元素的其他客户端不会获得从服务器发送的更新值。他们只是用他们的 minimongo 数据库中已有的内容进行更新。服务器端MongoDB确实显示了新条目,但除了创建它的客户端之外,我无法在任何客户端上查询它。
问题是我.find
使用了一个计算值数组,因此依赖系统没有再次调用我的发布事件吗?