Meteor.x27;t在查询中使用数组时更新客户端

Meteor.x27;t在查询中使用数组时更新客户端,meteor,Meteor,考虑以下代码: 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_childre

考虑以下代码:

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}});
});
在my Meteor.publish中,我动态生成一个id数组,用于我的
.find
。它可以用于手动查询数据,但当我向“共享”字段添加新元素时,只有添加该字段的客户机才会显示更新。查看同一元素的其他客户端不会从服务器发送更新的值。他们只需使用minimongo数据库中已有的内容进行更新。服务器端确实显示了新条目,但除了创建它的客户机之外,我无法在任何客户机上查询它


问题是my
.find
使用的是计算值数组,因此依赖关系系统不会再次调用my publish事件吗?

常见的误解是Meteor的Reactivity运行在服务器端。取而代之的是,典型的模式是客户端发生变化,客户端有一个被动变量(如会话对象)作为订阅的参数。订阅值的更改将导致使用新参数重新调用发布

相反,如果要在服务器端执行此操作,则需要设置一个观察者,如中所示