couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Anderson" <>
Subject Re: using reduce to get SQL distinct like results
Date Tue, 26 Aug 2008 22:09:36 GMT
I would avoid using a reduce at all in this case, and just request the
key-range corresponding to the particular user directly from the map.
You'll get all the information you need, and little extraneous
information. You can then munge the data into whatever shape you need
in your application. However, I bet you won't need to do much munging.

 "all": {
   "map": "function(doc) { emit(doc.User, doc.Date); }"

Reduce should be reserved for when you want to aggregate a scalar
value from a set of map rows. Eg, the number of messages a user
received in a given month, or some such. When you merely want all the
data from a map, about a given key, just query the map.


Chris Anderson

View raw message