0
votes

I have a document with this format in CouchDB:

{ 
      "box": 1, 
      "store": "New City", 
       "types": "sales"
}

I have the following map function:

function(doc) {
  if (doc.types == "sales") {
   if ( doc.box != null && doc.box != false)
    {
     emit(doc.box, doc.store);
     }
   }
}

I want to display the number of box for each store but I can't create a reduce function.

1

1 Answers

1
votes

If you emit the store as the key and the number of boxes as the value, then a built-in reduce function _sum (simply put _sum as the reduce function) will do the job.