Database
[{"collection":"mycollection","count":100,"content":{"trail":{"type":"faker","method":"BeerName","maxDistinctValue":10},"mytimestamp":{"type":"date","startDate":"2023-01-01T00:00:00Z","endDate":"2023-08-01T00:00:00Z"}},"indexes":[{"name":"trail_1","key":{"trail":1}},{"name":"mytimestamp_-1","key":{"mytimestamp":-1}},{"name":"trail_1_mytimestamp_-1","key":{"trail":1,"mytimestamp":-1}}]}]
Query
db.mycollection.aggregate([{"$group":{"_id":"$trail","updateCount":{"$count":{}},"mostRecentUpdate":{"$max":"$mytimestamp"}}}])