Here’s the thing. I know that in order to get reactivity on the server side publications working properly I need to keep my queries simple and avoid joins.
What I supposed though is that I could do something more similar to a join on the client, while keeping all the reactivity advantages. I’m trying to solve this avoiding to denormalize some more data on the Invitations
collection. I read what I could find on the Internet (like https://www.discovermeteor.com/blog/reactive-joins-in-meteor/) but they all discuss server side reactivity.
This is my case. I have an Invitations
collection and a Channels
collection. People receive invitations to join channels and they need to accept before joining. Channels can be archived, so when you archive a channel, you don’t want to show any open Invitation related to that channel anymore. To get my Invitations on the client template I created a helper like this:
//client library function
libGetListedChannels = function() {
return Channels.find({status: libChannelStatus.listed}).fetch().map(function(c){return c._id;});
}
...
//template helper
pendingInvitations: function() {
return Invitations.find({accepted : libInvitationStatus.pending,
guestId : Meteor.userId(),
channelId : {$in : libGetListedChannels()}});
Am I doing anything wrong or this is just a limit of reactivity on the client?