我有这种类型的文件:
{
"_id":ObjectId("527cedf19df815000700123b"),
"title":"title question",
"content": "content question",
"answer": [
{
"_id": ObjectId("527cee379df8155c1300002a"),
"content": "<p>answer 1<\/p>",
"total_dislike": NumberInt(10),
"total_like": NumberInt(20)
},
{
"_id": ObjectId("527d135b9df8152c04005ddd"),
"content": "<p>answer 2<\/p>",
"total_dislike": NumberInt(2),
"total_like": NumberInt(6)
}
]
}
我想创建一个查询 where answer.total_dislike > answer.total_like
.
我使用了这个查询:
> db.Question.find( { $where: "this.answer.total_dislike > this.answer.total_like" } );
但它不起作用。我如何编写查询以返回answer.total_dislike
大于的所有子文档answer.total_like
?