Created
August 16, 2010 17:17
-
-
Save jnunemaker/527321 to your computer and use it in GitHub Desktop.
A way of making map/reduce queries using a class
This file contains hidden or 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
module PageViewsByMonth | |
def map | |
<<-MAP | |
function() {…} | |
MAP | |
end | |
def reduce | |
<<-REDUCE | |
function() {…} | |
REDUCE | |
end | |
def build | |
Views.collection.map_reduce(map, reduce) | |
end | |
extend self | |
end | |
# Usage: PageViewsByMonth.build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like this idea because it separates out the map and reduce quite nicely so you can see what is going on without muddling your models.