how to find maximum of 5 data in mongo db code example
Example 1: mongodb get maximum value from collection
db.collection.aggregate([{
$group : { _id: null, max: { $max : "$age" }}
}]);
Example 2: mongodb get max value
db.collection.find().sort({age:-1}).limit(1) // for MAX
db.collection.find().sort({age:+1}).limit(1) // for MIN