我不能用用户名填充评论。
postController.getFriendPosts = function(req,res) {
var CurrentUser = req.params.currentUserID;
console.log("CurrentUserid==>>>>>>>>>>>>>:", CurrentUser);
userModel.findOne({_id:CurrentUser})
.exec((err,result) => {
if (err) {
res.status(500).send(err);
}
postModel.find({'userId':{$in: result.friends}})
.populate('users') //it does not work
.populate('comment') //it works
.exec((err,posts) => {
if (err) {
res.status(500).send(err);
}
console.log("POSTS...",posts);
res.status(200).send(posts);
})
})
}