couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "ViewCollation" by PaulCarey
Date Wed, 23 Jul 2008 15:33:20 GMT
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 ==
  

Mime
View raw message