Method: MongoDoc::Contexts::Mongo#min

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

#min(field) ⇒ Object

Return the min 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.min(:age)

Returns:

A numeric minimum value.



205
206
207
# File 'lib/mongo_doc/contexts/mongo.rb', line 205

def min(field)
  grouped(:min, field.to_s, MIN_REDUCE)
end