MongoDB 聚合内排序 2019-07-21 MongoDB, 笔记 MongoDB 聚合内排序把分组的主键都归在一起,再去聚合排序 12345var group = {_id:{playerId:"$playerId"}, obj:{$push: {id:"$id",title:"$title",playerId: "$playerId",date: "$date"}}, dateMax: {$max: "$date"},count:{$sum:1}}; db.xxx.aggregate([{$sort:{playerId:1,date:-1}}, {$group: group},{$sort:{dateMax:-1}},{$skip:1*50},{$limit:50}]);