Answers for "mongodb get document with maximum value from collection"

0

mongodb get maximum value from collection

db.collection.aggregate([{
	$group : { _id: null, max: { $max : "$age" }}
}]);
Posted by: Guest on April-05-2021
0

mongodb get document with maximum value from collection

var group = {$group:{_id:"$age", names:{$push:"$name"}, count:{$sum:1}}}
var sort = {$sort:{"_id":-1}}
var limit= {$limit:1}
db.selrac.aggregate([group, sort, limit])
Posted by: Guest on April-05-2021

Code answers related to "mongodb get document with maximum value from collection"

Browse Popular Code Answers by Language