Method: Mongoid::Contexts::Enumerable#distinct
- Defined in:
- lib/mongoid/contexts/enumerable.rb
#distinct(field) ⇒ Object
Gets an array of distinct values for the supplied field across the entire array or the susbset given the criteria.
Example:
context.distinct(:title)
48 49 50 |
# File 'lib/mongoid/contexts/enumerable.rb', line 48 def distinct(field) execute.collect { |doc| doc.send(field) }.uniq end |