Mongodb aggregate

  mongodb, question

Question: There is a set of data similar to the following

How can I get the latest updateTime through aggregate and count the number with status 2?

I don’t know if I understand what I mean to you. The latestupdateTimeIf you are referring to the pressstatusAfter grouping, each group is the latest. That is how it is written:

 {$group: {_id: "$status", updateTime: {$max: "$updateTime"}, count: {$sum: 1}}}