Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 820EE103D3 for ; Sun, 21 Apr 2013 00:26:23 +0000 (UTC) Received: (qmail 10095 invoked by uid 500); 21 Apr 2013 00:26:23 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 9999 invoked by uid 500); 21 Apr 2013 00:26:23 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 9963 invoked by uid 99); 21 Apr 2013 00:26:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Apr 2013 00:26:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.131] (HELO eos.apache.org) (140.211.11.131) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Apr 2013 00:26:20 +0000 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id 775F2659; Sun, 21 Apr 2013 00:25:59 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Apache Wiki To: Apache Wiki Date: Sun, 21 Apr 2013 00:25:59 -0000 Message-ID: <20130421002559.50598.89690@eos.apache.org> Subject: =?utf-8?q?=5BCouchdb_Wiki=5D_Update_of_=22IsoFormattedDateAsDocId=22_by_B?= =?utf-8?q?enjaminYoung?= Auto-Submitted: auto-generated X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for c= hange notification. The "IsoFormattedDateAsDocId" page has been changed by BenjaminYoung: http://wiki.apache.org/couchdb/IsoFormattedDateAsDocId?action=3Ddiff&rev1= =3D9&rev2=3D10 Comment: added Archive.org cached version of the migrating-to-couchdb doc =3D Using an ISO Formated Date as a Doc _id =3D - = The ISO 8601 http://en.wikipedia.org/wiki/ISO_8601 standard describes a u= seful scheme for representing a date string in a Year-Month-DayTHour:Minute= :Second.microsecond format. For time-bound documents in a CouchDB database = this can be a very handy way to create a unique identifier, since javascrip= t can directly use it to create a Date object: = {{{#!javascript @@ -12, +11 @@ } } }}} - = . . . then simply use group_level to zoom in on whatever time you wish to= use. = {{{#!javascript @@ -31, +29 @@ {"key":[21,thing],"value":10} ]} }}} - = Another method is using parseint() and datetime.substr() to cut out usefu= l values for a return key: = {{{#!javascript @@ -45, +42 @@ emit([doc.widget, year, month, day, hour, minute], 1); } }}} - = - = - = If you have python views enabled, you can use the datetime module in the = same way: = {{{#!python @@ -56, +50 @@ dt =3D 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 }}} - = . . .example with reduce function as it appears in the design doc: = {{{#!javascript @@ -67, +60 @@ } } }}} - A nice example using a date within a document is found here: http://www.c= ouchone.com/migrating-to-couchdb#three + A nice example using a date within a document is found here: http://www.c= ouchone.com/migrating-to-couchdb#three [dead link] [[http://web.archive.org= /web/20110130042049/http://www.couchone.com/migrating-to-couchdb#three|Arch= ive.org copy]] =20