Hey guys,
I’m having some trouble with a reactive publish method. I try to publish all “likes” with information about the user who liked me. This is my function:
Meteor.publish('likes', function () {
var gotLiked = Likes.find({user2: this.userId});
var allLikes = gotLiked.fetch();
likeArray = [];
_.each(allLikes, function (like) {
likeArray.push(like.user1);
});
var users = Users.find({_id: {$in: likeArray}}, {
fields: {
'profile.picture': 1,
'profile.gender': 1, 'profile.peerkey': 1
}
});
return [users, Images.find({'owner': {$in: likeArray}}), gotLiked]
});
When someone likes me, I get a visual information in my template. But when I open it, there is only an empty div, meaning he doesn’t get the user information (gender and picture).
When I execute “Users.find().count()” in my browser console, I only get my own account. The funny thing is, if I reload the page and reopen the notification again, all information about the user that liked me are available.
user2 is the user that’ve been liked (me) and user1 contains the id of the user who liked. I get still like notifications, but they are empty. My helpers look like this: