mongodb how to get max value from collections

As one of comments:

db.collection.find().sort({age:-1}).limit(1) // for MAX
db.collection.find().sort({age:+1}).limit(1) // for MIN

it’s completely usable but i’m not sure about performance

Leave a Comment