Mongodb 猫鼬是怎么做的
如何在评论中找到评论Mongodb 猫鼬是怎么做的,mongodb,mongoose,Mongodb,Mongoose,如何在评论中找到评论 comments: [{ nickName: {type: String, required: true}, comment: {type: String, required: true}, commentUnders: [{ nickName: {type: String, required: true}, comment: {type: String, required: true}, }] }]
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);
});
您的评论文档中的“_id”在哪里?@JBone mongo默认创建了该文档。这一切都很好。