【发布时间】:2012-12-06 17:27:35
【问题描述】:
考虑这段代码:
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 使用了一个计算值数组,因此依赖系统没有再次调用我的发布事件吗?
【问题讨论】:
标签: meteor