incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas.B...@ptb.de
Subject I'm going mad with reduce
Date Fri, 14 Aug 2009 13:41:31 GMT
Dear users,

I like to provide check-box input with a view.
The couchdb contains  an key named Standard with
90 values "CE3", 2 values "SE2", 1 value "C1" ...

Now the view should deliver each value 1 times.
After two hours playing with reduce I give up at this point:

map:function(doc) {
if(doc.Calibration.Standard){
var standard = doc.Calibration.Standard;
;
  emit(standard, {"Standard": standard });
}
}
reduce:function(k, v, c){

var res = {};
var star = new Array();
var j =0;

for(var i=0; i< v.length; i++) {

var stdr = v[i].Standard;

if(!(res[stdr])){

res[stdr] = ;
star[j] = v[i].Standard;
j +=1;

}

}
var conStr = star.toString(); 
var back = {Standard:conStr}
return back ;

}

I get something like
{"rows":[
{"key":null,"value":{"Standard":"CE3,SE2,CE3,CE2,CE1"}}
]}


When I use the "raw" http://server:5984/db/_design/reduce/_view/standard-1
you see that CE3 is listed two times ??

I think this is a kick self problem,
can you kick me?

Regards
Thomas



Mime
View raw message