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)
];
});