Example

Reducers

Creating a reducer is similar. The user defines a block to serve as the reduce function.

reduce

The block passed to reduce should take two arguments, a key and an array of values. It should iterate over the values and reduce the data by producing a single document that has an _id field with the key and other fields with some reduction of the data (sum, count, etc...)

kvreduce

The key-value reducer should function similarly in that it takes a key and array of values but returns an array with the key as the first element and a value as the second.