couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kiran Lonikar <kloni...@yahoo.com>
Subject Getting map results in key --> array of values format
Date Tue, 30 Aug 2011 06:17:43 GMT
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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message