From user-return-8948-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Thu Feb 25 00:50:06 2010 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 37390 invoked from network); 25 Feb 2010 00:50:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Feb 2010 00:50:06 -0000 Received: (qmail 26697 invoked by uid 500); 25 Feb 2010 00:50:05 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 26629 invoked by uid 500); 25 Feb 2010 00:50:05 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 26621 invoked by uid 99); 25 Feb 2010 00:50:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Feb 2010 00:50:05 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of travisladuke@gmail.com designates 209.85.223.172 as permitted sender) Received: from [209.85.223.172] (HELO mail-iw0-f172.google.com) (209.85.223.172) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Feb 2010 00:49:58 +0000 Received: by iwn2 with SMTP id 2so5211922iwn.29 for ; Wed, 24 Feb 2010 16:49:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=X+Z4zmXvggbm/IgqCslu3SFrDVNFzg9mTC/k9Lk4JKw=; b=qvIbjSRtZIiHJFCNmMjrUkWst2ADzCKvM4leeR1qX5HFG8bVOrk6q4fCv+lQDJcwgF oiROX1JNcjwbOhuwMpeJ9V5ELfGglKo6MlcMFLqT9RYnwgwNGIEW8HrFsQp7XBrZOdZ0 pWEEm/ZOMMXCv8tCVaNsxfMUd7Dc1MINco6zI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=bjKu7XEmznPnTr2/ltMnvFyoD3ZjAKNeYTK6PB8WshFIF3++wf3H14WO1+9f0hHzTU Ozb5UpZc3okVnGkHXAgqsRDl7d2Gs6HHms6u96Q9KMpztYAK6uFgEbsIhMSYD9YjQ7jB v1HbvaIFx2Y72ucOWewDH3QthmNjcnWK0ae2A= MIME-Version: 1.0 Received: by 10.231.147.18 with SMTP id j18mr467586ibv.82.1267058977823; Wed, 24 Feb 2010 16:49:37 -0800 (PST) In-Reply-To: <594289661002241624l62235922lb4e43c8c389a0ffc@mail.gmail.com> References: <1e98902e1002241534p51e240fm32977bb0ca93ccaf@mail.gmail.com> <594289661002241624l62235922lb4e43c8c389a0ffc@mail.gmail.com> Date: Wed, 24 Feb 2010 16:49:37 -0800 Message-ID: <1e98902e1002241649x52f594d2v9c7677225e3b3e5c@mail.gmail.com> Subject: Re: Order posts by most recently commented on? From: Travis LaDuke To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Wed, Feb 24, 2010 at 4:24 PM, David Goodlad 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) { > =A0if(doc.type =3D=3D 'comment') { > =A0 =A0emit(doc.post_time, {"id": doc.topic_id}); > =A0} > } > > You could then query that view with include_docs=3Dtrue 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?