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] Trivial Update of "IsoFormattedDateAsDocId" by DougShawhan
Date Fri, 25 Feb 2011 18:27:23 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The "IsoFormattedDateAsDocId" page has been changed by DougShawhan.
http://wiki.apache.org/couchdb/IsoFormattedDateAsDocId?action=diff&rev1=2&rev2=3

--------------------------------------------------

  }
  }}}
  
- Another advantage is using parseint() and datetime.substr() to cut out useful values for
a return key: 
+ Another advantage is using parseint() and datetime.substr() to cut out useful values for
a return key:
  
  {{{#!javascript
  function (doc) {
@@ -49, +49 @@

  If you have python views enabled, you can use the datetime module in the same way:
  
  {{{#!python
- def fun( doc ): 
+ def fun(doc):
      from datetime import datetime
-     dt = datetime.strptime( doc._id, "%Y-%m-%dT%H:%M:%S.%f" )
+     dt = datetime.strptime(doc._id, "%Y-%m-%dT%H:%M:%S.%f")
-     yield( [doc.host, dt.year, dt.month, dt.day, dt.hour, dt.minute ], 1 )
+     yield [doc.host, dt.year, dt.month, dt.day, dt.hour, dt.minute], 1
  }}}
  
  . . .example with reduce function as it appears in the design doc:

Mime
View raw message