Hi say I had product documents that looked like this (formatted for
readability):
{
"_id":"p9",
"_rev":"2-9a109fb7d9f116441876e0d6401ec1ba",
"product_name":"Apple iPhone 3Gs 32GB",
"Stores":[
{
"name":"Store A",
"item_count":558
},
{
"name":"CompuShop",
"item_count":4878
},
{
"name":"Kerry's Computer Shop",
"item_count":54474
}
]
}
and a view function:
function(doc)
{
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
.../_design/inventory/_view/total_items
{"rows":[
{"key":null,"value":8452613}
]}