couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zachary Zolton <zachary.zol...@gmail.com>
Subject Re: Getting map results in key --> array of values format
Date Tue, 30 Aug 2011 13:46:45 GMT
Kiran,

Using a list function is the appropriate tool for reformatting the
output of a view query.

If you don't want to chop off some values, then why are you using limit? (^_-

Perhaps, you could query this same view with a _sum reduce? That way
you can know how many values would come back per key.

I think we'll need to hear more to help you here.


Cheers,

Zach

On Tue, Aug 30, 2011 at 1:17 AM, Kiran Lonikar <klonikar@yahoo.com> wrote:
> Hi,
>
> I just started using couchdb. I have the following question:
> Currently the results of map are returned in the following format:
>
> {
> "total_rows": 3,
> "offset": 0,
> "rows": [
> {
> "key": "key1",
> "id": "doc-id1",
> "value": "value1"
> },
>
> {
> "key": "key1",
> "id": "doc-id2",
> "value": "value2"
> },
>
> {
> "key": "key2",
> "id": "doc-id3",
> "value": "value3"
> }
> ]
> }
>
> Is it possible to condense the same "key" rows and get the results in the format below:
>
> {
> "rows": [
> {
> "key": "key1",
> "value": ["value1", value2]
> },
>
> {
> "key": "key2",
> "value": "[value3]"
> }
> ]
> }
>
> I think I will have to use a list function to format the view results since there are
no view parameters to do this and also since I do not want to use the reduce function.
>
> The list function is complicated by the fact that if I use limit and startkey parameters
of the view, it is likely that limit may chop off some values for the last key and those values
will not appear in the list output.
>
> Instead, I would like to know if there is any option where couchdb view retrieval itself
can be changed to retrieve the output in the way I want.
>
> Thanks,
> Kiran

Mime
View raw message