incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Hammond <josephhamm...@hotmail.com>
Subject RE: get by value, order by time
Date Sat, 10 Mar 2012 15:17:06 GMT
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


Mime
View raw message