Publication query update when find in publication is updated


#1

Hi Guys,

I have the following publication with the meteor-publish-composite package:

`Meteor.publishComposite(‘followersWallMessages’, function() {
return {
find: function() {

        var followersCursor = followCollection.find({userId: this.userId});
        var toFollowIds = followersCursor.map(function (followRecord) { return followRecord.isFollowing });

        return WallMessagesCollection.find({userId: {$in : toFollowIds}});
    },
    children: [
        {
            find: function(message) {
                return Meteor.users.find(
                    { _id: message.userId },
                    { limit: 1, fields: { profile: 1 } });
            }
        },
        {
            find: function(message) {
                if (message.pictureId != undefined) {
                    return Images.find(
                        { _id: message.pictureId });
                }
            }
        },
        {
            find: function(message) {
                if (message.videoId != undefined) {
                    return Videos.find(
                        { _id: message.videoId });
                }
            }
        },
        {
            find: function(message) {
                console.log(followCollection.find({userId: this.userId}).fetch());
                return followCollection.find({userId: this.userId});
            }
        },
    ]
}

});`

You see that I first query the id’s of the person the client is following (cant send this by the client for security reasons). What I want to do is, once this followerscollection is updated make sure that this publication publishes again.

I was thinking on returning multiple cursors, but this is not possible in this case because of the package I am using for the relations.

Any other ideas ?