Mongo aggregation framework, Sort and then group not working
问题 I am trying sort data by date first and then group on another field. It is not working to me. The question I am trying to answer is: Select the most recent distinct cid? given this data: db.summary.save({"lid" : 5, "date" : 5, "cid" : 2, "circles" : [ 2 ] }) db.summary.save({"lid" : 2, "date" : 2, "cid" : 1, "circles" : [ 2 ] }) db.summary.save({"lid" : 4, "date" : 0, "cid" : 3, "circles" : [ 2 ] }) db.summary.save({"lid" : 3, "date" : 3, "cid" : 2, "circles" : [ 2 ] }) db.summary.save({"lid"