I have 3 columns in the collection, they are '_id', 'value' and 'time'.
I've use below code get the id with max time
pipeline = [{'$group': {'_id': '$_id', 'time': {'$max': '$time'}}}]
values = list(db.fund_cost_log.aggregate(pipeline))
But I also want the value at the document with max time after group by id, how should I do it?
----- update ------
It's not duplicate with this, the answer of that one only gets the max time, I want the max time for each distinct id.