因此,如果我执行以下操作:
Chat.findOne({ user: req.user._id })
.populate({ path: 'chat_list.participants' })
.then((chat) => {
res.json(chat);
})
输出如下:
{
"_id": "5c7ff03f8ae0be31a0b7002f",
"chat_list": [
{
"participants": [
{
"securityQuestions": {
"isSetup": false
},
"videos": [],
"events": [],
"_id": "5c7d66065619c542e81583c6",
"name": "Tobi Uchiha",
"email": "tobi@gmail.com",
"date": "2019-03-04T17:53:10.267Z",
"__v": 0,
"profile": "5c7d66065619c542e81583ca",
"profile_type": "PartnerAdminProfile"
}
],
"messages": [],
"_id": "5c800d7997f7d74bacade2a6"
}
],
"user": "5c7f36d7e7a5c04e5046e8ca",
"chat_history": [],
"__v": 0
}
我也在尝试填充个人资料。但是如果我做这样的事情 .populate({path:'chat_list.participants.profile'})它刚刚退出。如何在填充的参与者数组中填充嵌套的个人资料?
答案 0 :(得分:0)
发布后,Welp立即解决了
.populate({ path: 'chat_list.participants', populate: { path: 'profile' } })