Method: MongoDoc::Contexts::Mongo#max

Defined in:
lib/mongo_doc/contexts/mongo.rb

#max(field) ⇒ Object

Return the max value for a field.

This will take the internally built selector and options and pass them on to the Ruby driver’s group() method on the collection. The collection itself will be retrieved from the class provided, and once the query has returned it will provided a grouping of keys with sums.

Example:

context.max(:age)

Returns:

A numeric max value.



185
186
187
# File 'lib/mongo_doc/contexts/mongo.rb', line 185

def max(field)
  grouped(:max, field.to_s, MAX_REDUCE)
end