Publication doesn't send down new data

I have a Team object that contains a field called userIds that can be changed by the user. When the client adds a new userId to the array, the new team.userIds is properly sent down to the client. However, the user object associated with this new userId is not being sent down as well. Not sure what’s going on. The console.log calls aren’t fired either.

My publication is as follows:

  const TEAMS_SINGLE = 'teams.single';
  Meteor.publish(TEAMS_SINGLE, function ({teamId}) {
    check(arguments[0], {
      teamId: String
    });

    const userId = this.userId;
    const team = Teams.findOne(teamId);

    const userFields = {
      username: 1,
      [`roles.${teamId}`]: 1,
      emails: 1
    };

    console.log('team.userIds');
    console.log(team.userIds);

    return [
      Meteor.users.find({_id: {$in: team.userIds}}, {fields: userFields}),
      Teams.find(teamId)
    ];
});

publications are not reactive by default. There are packages for this, but I’ve now resorted to joining on the client - seems more stable.

By joining on the client you mean you make another subscription users that looks like

Meteor.publish('users', function ({userIds}) {
  return Meteor.users.find({_id: {$in: userIds}});
});

Then just update the sub with the new team.userIds when the team gets updated so that you can get the new users?

Hmm, I’m not even sure if that is reactive unfortunately.

What I meant is subscribe to both collections and use coll.find(userIds) as the filter.