couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabriel de Oliveira Barbosa <manobi.olive...@gmail.com>
Subject Re: [object Object] instead of string
Date Sun, 15 Jan 2012 15:15:32 GMT
Just can't understand why in second how it working, given that all
documents have the same structure:

function map (doc){
for(var key in doc){
var output = {};
if(key != '_id' && key != '_rev'){
 output[key] = doc[key];
emit(doc.page_id + ':' + doc.date, output);
 }
}
};

function reduce (keys, values, rereduce){
 var hash = {};

values.forEach(function(pair){
for(var key in pair){
 hash[key] = hash[key] || {};
hash[key][pair[key]] = (hash[key][pair[key]] + 1) || 1;
 }
});
 return hash;
};

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message