I’m not sure. The query looks correct to me as long as my_groups is an array. If you but the query into a variable and log it, it is only returning your current user?
So there is no key groups. In the example above, I use groups which I create separately, so in this case the user is in group: ‘bTHwzLN7y4FLWRm7Z’. I don’t believe there are any getUsersForGroup or isUserInGroup methods, so probably best coding one up properly.
I think (from memory) the way i solved this was to come up with a array of groups. Then individually sort through users to work out an array of users who were in the specific group/specific role using userIsInRole(user, ['somerole], group]. The final return find then becomes a simpler check if id is in my user id array.
When I iterate through the all of Meteor.users.find() I access the users’ role like this: roles.default_group.[0]
So if I know that users will only ever have one group, I thought I’d try the publish statement like this: Meteor.publish('usersInMyGroup', function() { var my_group = Roles.getGroupsForUser(this.userId)[0]; var field = 'roles.'+my_group; return Meteor.users.find({field: {$exists: true}}, {fields:{emails:1, profile:1, roles:1}}); });
Once again, I only get one user (my current user) returned. Sigh.