ユーザーIDの配列にIDを持つすべてのユーザーを取得する方法を教えてください。 私の問題は、私はグループのコレクションを持っている、各グループはユーザーと呼ばれるuserIDsの配列を持っています、これらのユーザーはグループに属しています、私はそのユーザーIDの配列からユーザーオブジェクトを取得する方法を知る必要があります?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