I have a collection of Messages on my mongodb.
I have created two publish functions:
Meteor.publish("messages", function (self, buddy) {
check(self, String);
check(buddy, String);
return Messages.find({participants: {$all : [self, buddy] }});
});
and,
Meteor.publish("conversations", function(self){
check(self, String);
return Messages.find(
{ participants: { $in : [self] } },
{ participants: { $elemMatch: { $ne: self } }, messages: { $slice: -1 }}
);
});
And I subscribe to both of these on the client:
Meteor.subscribe("conversations", user);
return Messages.find();
and,
Meteor.subscribe("messages", user, buddy);
return Messages.find();
The subscriptions are located in different templates.
The problem is that when I return the data from the conversation
subscription the data is the same as from the messages
subscription. I see the same results in both subscriptions even though they have different queries...
How can I solve this issue?