1

我在 CouchDB 中定义了一个 map 函数,它生成如下所示的数据:-

 var data =
{"total_rows":10,"offset":0,"rows":[
    {"id":"338b79f07dfe8b3877b3aa41a5bb8a58","key":"2000-06-23T23:59:00+00:00","value":{"country":"United States"}},
    {"id":"338b79f07dfe8b3877b3aa41a5bb983e","key":"2000-06-23T23:59:00+00:00","value":{"country":"Norway"}},
    {"id":"338b79f07dfe8b3877b3aa41a5ddfefe","key":"2000-06-23T23:59:00+00:00","value":{"country":"Hungary"}},
    {"id":"338b79f07dfe8b3877b3aa41a5fe29d7","key":"2000-06-23T23:59:00+00:00","value":{"country":"United States"}},
    {"id":"b6ed02fb38d6506d7371c419751e8a14","key":"2000-06-23T23:59:00+00:00","value":{"country":"Germany"}},
    {"id":"b6ed02fb38d6506d7371c419753e20b6","key":"2000-06-23T23:59:00+00:00","value":{"country":"Hungary"}},
    {"id":"b6ed02fb38d6506d7371c419755f34ad","key":"2000-06-23T23:59:00+00:00","value":{"country":"United States"}},
    {"id":"b6ed02fb38d6506d7371c419755f3e17","key":"2000-06-23T23:59:00+00:00","value":{"country":"Germany"}},
    {"id":"338b79f07dfe8b3877b3aa41a506082f","key":"2003-01-08T19:34:00+00:00","value":{"country":"United Kingdom"}},
    {"id":"9366afb036bf8b63c9f45379bbe29509","key":"2003-01-08T19:34:00+00:00","value":{"":"United Kingdom"}}
]
}

我现在正在尝试创建生成如下数据的 reduce 函数:-

{"rows":[
{"key":"United States","value":2},
{"key":"Norway","value":1},
{"key":"Hungary","value":2},
{"key":"Germany","value":2}
{"key":"United Kingdom","value":1}

]}

我需要能够在沙发上使用“StartKey”和“EndKey”参数来定义日期范围。事实证明这比我预期的要棘手。有人可以告诉我我的 reduce 函数应该是什么样子来处理这个问题吗?

问候,

卡尔斯基

4

1 回答 1

0
于 2012-10-07T08:32:08.330 回答