Method: MongoDoc::Contexts::Mongo#min
- Defined in:
- lib/mongodoc/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.
163 164 165 |
# File 'lib/mongodoc/contexts/mongo.rb', line 163 def min(field) grouped(:min, field.to_s, MIN_REDUCE) end |