From user-return-20024-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Sat Mar 10 15:17:39 2012 Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 731B49A03 for ; Sat, 10 Mar 2012 15:17:39 +0000 (UTC) Received: (qmail 40623 invoked by uid 500); 10 Mar 2012 15:17:37 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 40572 invoked by uid 500); 10 Mar 2012 15:17:37 -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 40552 invoked by uid 99); 10 Mar 2012 15:17:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Mar 2012 15:17:36 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of josephhammond@hotmail.com designates 65.55.116.99 as permitted sender) Received: from [65.55.116.99] (HELO blu0-omc3-s24.blu0.hotmail.com) (65.55.116.99) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Mar 2012 15:17:27 +0000 Received: from BLU0-SMTP408 ([65.55.116.72]) by blu0-omc3-s24.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Sat, 10 Mar 2012 07:17:06 -0800 X-Originating-IP: [68.1.110.23] X-Originating-Email: [josephhammond@hotmail.com] Message-ID: Received: from testcasePC ([68.1.110.23]) by BLU0-SMTP408.phx.gbl over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Sat, 10 Mar 2012 07:17:04 -0800 From: John Hammond To: References: In-Reply-To: Subject: RE: get by value, order by time Date: Sat, 10 Mar 2012 10:17:06 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQGr1OvSQvjRcfF8U7PuWFl998/Ol5al9fIQ Content-Language: en-us X-OriginalArrivalTime: 10 Mar 2012 15:17:04.0454 (UTC) FILETIME=[D99D9E60:01CCFED0] X-Virus-Checked: Checked by ClamAV on apache.org You can use the following if you have a created_at attribute and sort by datetime. emit(Date.parse(doc.created_at).getTime(), doc); -----Original Message----- From: felix milea [mailto:felixmilea@gmail.com] Sent: Saturday, March 10, 2012 9:24 AM To: user@couchdb.apache.org Subject: get by value, order by time Hey guys, I'm new to CouchDB and I need help with an app I'm working on; I'm trying to get the 50 most recent posts a user made in the app. I created a view that pulls out the documents for the posts, and I can use the key parameter to get only the posts of a particular user and the limit parameter to get only 50 entries. However, I'd like to order the returned docs by a "timestamp" field (which stores the new Date().getTime() of when the entry was made) in order to ensure that the posts are the most recent ones. How can I do this in CouchDB? -- Felix Milea-Ciobanu