【发布时间】:2015-09-23 01:12:37
【问题描述】:
我的 mongodb 上有一组消息。
我创建了两个发布函数:
Meteor.publish("messages", function (self, buddy) {
check(self, String);
check(buddy, String);
return Messages.find({participants: {$all : [self, buddy] }});
});
和,
Meteor.publish("conversations", function(self){
check(self, String);
return Messages.find(
{ participants: { $in : [self] } },
{ participants: { $elemMatch: { $ne: self } }, messages: { $slice: -1 }}
);
});
我在客户端订阅了这两个:
Meteor.subscribe("conversations", user);
return Messages.find();
和,
Meteor.subscribe("messages", user, buddy);
return Messages.find();
订阅位于不同的模板中。
问题是当我从conversation 订阅返回数据时,数据与来自messages 订阅的数据相同。我在两个订阅中看到相同的结果,即使它们有不同的查询......
我该如何解决这个问题?
【问题讨论】:
标签: mongodb meteor publish-subscribe