incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Trümper <>
Subject Re: 'Grouping' documents so that a set of documents is passed to the view function
Date Fri, 19 Jun 2009 07:43:31 GMT

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, );

An in the reduce function you have the values to do the computation  

function(keys, values, rereduce) {
   // do computations with all values


View raw message