Michael Hendricks wrote:
On Tue, Aug 26, 2008 at 05:01:56PM -0400, Joel Reed wrote:
I have a bunch of documents that look vaguely like this:

[{ "User":"Jane Doe", "Date":"2008/08/12", } { "User":"Jane Doe", "Date":"2008/08/15", }, etc...]

IOW, There might be several entries for each user all with different dates.

I'd like tp combine all "Jane Doe's" records into 1 entry. Some kind of output like:

"rows": [ {"key": "Jane Doe", "value": [
{"id":"481bf9e8a0c23bb61eeed4b3707bae59","Date":"2008/08/12"},
{"id":"1e6e541b391efcb9c137d7097e7de6ed","Date":"2008/08/15"}
] } ]

How about something like this:

 "all": {
   "map": "function(doc) { emit(doc.User, doc.Date); }",
   "reduce": "function(keys, values) {
        var results = new Array();
        for ( var i in values ) {
            results.push({
                id   : keys[i][1],
                Date : values[i]
            });
        }

        return results;"
  }
}

Thanks Michael, I'll give this a try. The results look alot nicer.

jr

Reply via email to