1

次のようなデータを生成するマップ関数をCouchDBで定義しました:-

 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}

]}

日付範囲を定義するために、Couchの「StartKey」および「EndKey」パラメーターを使用できるようにする必要があります。これは私が予想していたよりも難しいことを証明しています。誰かがこれを処理するために私のreduce関数がどのように見えるべきかを教えてもらえますか?

よろしく、

カールスキー

4

1 に答える 1

0
于 2012-10-07T08:32:08.330 に答える