incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject How do I SUM(values in a field array) using Views
Date Wed, 02 Jun 2010 05:38:00 GMT
Hi say I had product documents that looked like this (formatted for 

"product_name":"Apple iPhone 3Gs 32GB",
                 "name":"Store A",
                 "name":"Kerry's Computer Shop",

and a view function:
  for (id in doc.Stores)
    if(doc.product_name && doc.Stores[id].item_count)
      emit(doc.product_name, doc.Stores[id].item_count);

and a reduce function:
function(keys, values) {
   return sum(values);

Why, when I look at the resulting view in Futon does it look correct but 
when I view in browser it gives me a null key and a total of all items as 
opposed to one for each product? Or if I specify a product using ?key= , 
why do i still get key:null 


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