Sort by date in mongoose aggregation framework

后端 未结 3 1655
Happy的楠姐
Happy的楠姐 2021-02-13 21:57

Im working on a nodejs+mongodb project using mongoose. Now I have come across a question I don\'t know the answer to. I am using aggregation framework to get grouped results. T

3条回答
  •  旧时难觅i
    2021-02-13 22:18

    It appears that this question has a very simple answer :) Just need to sort by multiple nesteed columns like this:

    {$sort: {"date.year":1, "date.month":1, "date.day":1}}
    

提交回复
热议问题