组织者,产品集合,我需要加入带有已发布用户ID和组织者集合的产品表,并再次与用户和组织者一起购买用户ID。我可以与用户加入产品,但不能与组织者加入用户。
Products.find({})
.populate({
path: 'intresteduserIds.userId',
// Get friends of friends - populate the 'friends' array for every friend
populate: { path: 'intresteduserIds.user_organizationid' } /* How to join with organizer collection which have organizer id*/
})
.populate('product_postedby');
您需要在内部填充中设置model
属性。
因此,请在代码中导入Organizer
模型,并像这样使用它:(请注意,管理器周围没有任何字符串。)
Products.find({})
.populate({
path: 'intresteduserIds.userId',
populate: { path: 'intresteduserIds.user_organizationid', model: Organizer }
})
.populate('product_postedby');