diff --git a/content/patterns/unique_items_map_reduce.txt b/content/patterns/unique_items_map_reduce.txt index 8bdd9a6..a9d1691 100644 --- a/content/patterns/unique_items_map_reduce.txt +++ b/content/patterns/unique_items_map_reduce.txt @@ -60,7 +60,7 @@ The reduce function is trivial, as it simply performs a count: <% code 'javascript' do %> -reduce = "function(key, values) { +reduce = function(key, values) { var count = 0; values.forEach(function(v) { @@ -68,7 +68,7 @@ reduce = "function(key, values) { }); return {count: count}; -}" +} <% end %> ##### Run the command @@ -87,9 +87,9 @@ Now that we have a prelimiary set of results, we can do a second pass to count u Here's the map function: <% code 'javascript' do %> -map = "function() { +map = function() { emit(this['_id']['day'], {count: 1}); -}" +} <% end %> Because the first result set will store the *emit* key within an '_id' field, we have to reach into