对于这种情况,函数Reduce CouchDB

Function Reduce CouchDB for this case

本文关键字:Reduce CouchDB 函数 于这种 情况      更新时间:2023-09-26

我在CouchDB:中有一个这样格式的文档

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

我有以下地图功能:

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

我想显示每个商店的盒子数量,但我无法创建reduce函数。

如果将存储作为关键字,将框数作为值,则内置的reduce函数_sum(只需将_sum作为reduce功能)即可完成此任务。