Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions content/patterns/unique_items_map_reduce.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ 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) {
count += v['count'];
});

return {count: count};
}"
}
<% end %>

##### Run the command
Expand All @@ -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
Expand Down