Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Here I’ll provide some extra details on MongoDB’s aggregation functions.
You’ll commonly need to find min and max values for a given value in a collection. Databases using SQL provide special min() and max() functions, but MongoDB doesn’t. Instead, you must specify these queries literally. To find a maximum value, you can sort descending by the desired value and limit the result set to just one document. You can get a corresponding minimum by reversing the sort. For example, if you wanted to find the review with the greatest number of helpful votes, your query would need to sort by that value and limit by one: