You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by Apache Wiki <wi...@apache.org> on 2008/07/23 17:33:20 UTC
[Couchdb Wiki] Update of "ViewCollation" by PaulCarey
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.
The following page has been changed by PaulCarey:
http://wiki.apache.org/couchdb/ViewCollation
The comment on the change is:
Added sorting with dates section
------------------------------------------------------------------------------
}}}
This trick was [http://www.cmlenz.net/blog/2007/10/couchdb-joins.html originally documented] by Christopher Lenz.
+
+ === Sorting with Dates ===
+
+ It maybe be convenient to store date attributes in a human readable format (i.e. as a String), but still sort by date. This can be done by converting the date to a number in the emit function. For example, given a document with a created_at attribute of 'Wed Jul 23 16:29:21 +0100 2008', the following emit function would sort by date
+ {{{
+ emit(Date.parse(doc.created_at), doc);
+ }}}
+
== Collation Specification ==