Reputation: 15079
I'm guessing the answer is no, but is this possible? It seems like this is too much code for something so simple:
ary = []
obj.all.each {|o| ary << o[:foo]}
ary.uniq!
Upvotes: 1
Views: 996
Reputation: 303431
Separate from Mongo, you can write that same functionality in Ruby better as:
ary = obj.all.map{ |o| o[:foo] }.uniq
Edit: It looks like Mongo supports this via distinct
:
ary = @db['pageviews'].distinct('ip-address')
See the documentation for more details.
Upvotes: 3