Hi,
I am somewhat new to CouchDB but have been doing some stuff with it
and this is my first post to the list so pardon if I am wrong :)
> It would be really cool if there were some way to pass all the docs
> with a value of 1 for group_key to a single map function call, so I
> could do computation across those related documents and emit the
> results ... I'm just using the magic group_key attribute as an
> example, if such a feature were to actually be made I'd think you'd
> define a javascript function which returned a single groupping k to
> exist I
I think this is what the reduce function is for. In your map function
you could do something like this:
function(doc) {
if( doc.group_key == 1 ) {
emit( null, doc.data );
}
}
An in the reduce function you have the values to do the computation
with:
function(keys, values, rereduce) {
// do computations with all values
}
Daniel
|