couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeremy Wall" <jw...@google.com>
Subject Re: Associating users and comments
Date Thu, 02 Oct 2008 20:00:24 GMT
On Thu, Oct 2, 2008 at 2:49 PM, Alan Bell <
alan.bell@theopenlearningcentre.com> wrote:

> Jeremy Wall wrote:
> > Or you can create a last 5 posts for users view. There is nothing wrong
> with
> > that.
> But you can't can you? You could create a view of posts for a user and
> retrieve the top 5 rows, but you can't control a documents presence in
> the view based on the number of other documents that may or may not be
> in the view already I think. Maybe I am being overly pedantic here!


sure you can:

function(keys, values) {
  var sorted = sort(values);
  return [values[0], values[1], values[2], values[3], values[4]];
}

the above really really simplistic reduce demonstrates that you can return
sorted subsets of a value for a given key.

With a little key inspection you can deterministically return subsets for
only certain key types.

Jeremy

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message