有没有办法在mongo查询中对子文档进行排序?示例(博客集合):
{ "_id" : ObjectId("4c69d19532f73ad544000001"), "content" : "blah blah blah", "comments" : { {"author": "jim", "content":"comment content 1", "date" : "07-24-1995"}, {"author": "joe", "content":"comment content 2", "date" : "07-24-1996"} {"author": "amy", "content":"comment content 3", "date" : "09-10-1999"} } } { "_id" : ObjectId("4c69d19532f73ad544000002"), "content" : "blah blah blah", "comments" : { {"author": "jim", "content":"comment content 1", "date" : "07-24-1995"}, {"author": "joe", "content":"comment content 2", "date" : "07-24-1996"} {"author": "amy", "content":"comment content 3", "date" : "07-24-1997"} } }
我希望按照我决定的方式订购我的博客文章,然后在我的博客帖子中通过按日期反向排序或我想要的任何其他排序来订购评论.这可能与mongoDB有关吗?