mongodb - Mongo filter results by distinct field -
i utilize ruby driver mongo : https://github.com/mongodb/mongo-ruby-driver
i have many documents in collection :
{ "_productid" => 10 .... } { "_productid" => 10 .... } { "_productid" => 12 .... }
what request documents distinct "_productid", mean want take first , lastly collection item in exemple.
@db['collection'].distinct('_productid')
http://docs.mongodb.org/manual/reference/method/db.collection.distinct/
http://wiki.summercode.com/mongodb_aggregation_functions_and_ruby_counting_and_grouping
mongodb
No comments:
Post a Comment