How can I get every user that has an ID in an array of user IDs. My problem is I have a collection of groups, each group has an array of userIDs called users, these users belong to the group, I need to know how to get the user objects from that array of UserID's whats the best way to do that?
client
export default createContainer((props) => {
let user = Meteor.users.findOne(Meteor.userId())
let groupsSub = Meteor.subscribe('groups')
if (user) {
let code = user.profile.selectedGroup
let group = Groups.findOne({code})
return {
ready: groupsSub.ready(),
group,
users: Meteor.users.find({_id: {$in: group.users}}).fetch()
}
}
return {}
}, HomePage)
sever
Meteor.publish('groups', function () {
return Groups.find({
users: {
$elemMatch: { $eq: this.userId }
}
})
})
and this is where I'm trying to get the users
render () {
if (this.props.ready) {
let group = this.props.group
let users = this.props.users
console.log(users)
return (
<div className='c-fit-group'>
<div className='c-fit-group__header'>
<h1>{group.name}</h1>
</div>
</div>
)
}
return <div>Loading...</div>
}
}
also I'm using React for the front end

