Created
October 23, 2012 15:08
-
-
Save johnantoni/3939298 to your computer and use it in GitHub Desktop.
mongoid group by
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
products.collection.group(:key => 'family', :initial => {count: 0}, :reduce => "function(doc,prev) { prev.count += +1; }") | |
products.collection.group(:keyf => 'function(doc) { return {family: doc.family};}', :initial => {count: 0}, :reduce => "function(doc,prev) { prev.count += +1; }", :finalize => 'function(doc) { doc; }') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pardon my french here but why the fuck does mongo syntax query look like hell on earth?