사용자 ID 배열에 ID가있는 모든 사용자를 얻으려면 어떻게해야합니까? 제 문제는 그룹 컬렉션입니다. 각 그룹에는 사용자라고하는 userID라는 배열이 있습니다.이 사용자는 그룹에 속해 있습니다. UserID 배열에서 사용자 개체를 가져 오는 방법을 알아야합니다. ?MeteorJs 사용자 ID 배열이있는 모든 사용자 찾기
클라이언트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)
단절
Meteor.publish('groups', function() {
return Groups.find({
users: {
$elemMatch: { $eq: this.userId }
}
})
})
이 내가 얻으려고 어디 사용자 또한 내가 프런트 엔드
동안 반응 사용하고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>
}
}
I c onsole.log group.users 나는이
를 얻을 내가 사용자를 CONSOLE.LOG 때 간단하게 (내가 그라면 이야기하는 데 문제가 사용자 ID의 배열을 가지고 있다면이
지금까지 해보신 것은 무엇입니까? – jordanwillis