I am seriously baffled by mongodb\'s aggregate function. All I want is to find the newest document in my collection. Let\'s say each record has a field \"created\"
query = [ { '$sort': { 'created': -1 } }, { $group: { '_id':null, 'max':{'$first':"$$ROOT"} } } ] db.collection.aggregate(query)