incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Travis LaDuke <travislad...@gmail.com>
Subject Re: Order posts by most recently commented on?
Date Thu, 25 Feb 2010 00:49:37 GMT
On Wed, Feb 24, 2010 at 4:24 PM, David Goodlad <david@goodlad.ca> wrote:
> If you have comments stored as individual docs, with an associated
> topic doc on each, you could use a map function like:
>
> function(doc) {
>  if(doc.type == 'comment') {
>    emit(doc.post_time, {"id": doc.topic_id});
>  }
> }
>
> You could then query that view with include_docs=true to get all the
> topics sorted by comments' post times. You'd probably want a list
> function that would remove duplicates, since each topic would be
> included in the view once per comment in that topic.
>

Thanks, I didn't know about include_docs. I had thought of this before
(without the include_docs), but gave up when I thought it would make
it hard to paginate. If I say like limit 10, and there's a thread with
10 comments, I'll only get one topic in the list. Is there a way?

Mime
View raw message