如何在猫鼬中找到一个

时间:2017-03-07 09:41:46

标签: mongodb mongoose

如何在commentUnders中找到评论?

comments: [{
    nickName: {type: String, required: true}, 
    comment: {type: String, required: true}, 
    commentUnders: [{
        nickName: {type: String, required: true}, 
        comment: {type: String, required: true}, 
    }]
}]

我尝试了这个,但它没有用。

Post.findOne({'comments._id' : req.body._idComment}, 
    {'comments._id': $elemMatch: req.body._idComment,
     'commentUnders._id': $elemMatch: req.body._idCommentUnders}, function(err, data) {
   console.log(data);
});

0 个答案:

没有答案