我有一个集合评论。每条评论都有一个authorId。我想按authorId将comments集合分组到“threads”中,并附上5个最近的评论。到目前为止我已经试过了:db.comments.aggregate([{$group:{_id:"$authorId",recentComments:{$push:"$$ROOT"}}}])但这会附加所有评论。然后我尝试添加这样的限制:db.comments.aggregate([{$group:{_id:"$authorId",recentComments:{$push:"$$ROOT"}}},{$limit:5}])但这并没有限制文档的数