Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 63947 invoked from network); 10 Jun 2010 18:48:37 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 10 Jun 2010 18:48:37 -0000 Received: (qmail 32277 invoked by uid 500); 10 Jun 2010 18:48:36 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 32249 invoked by uid 500); 10 Jun 2010 18:48:36 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 32241 invoked by uid 99); 10 Jun 2010 18:48:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jun 2010 18:48:36 +0000 X-ASF-Spam-Status: No, hits=1.8 required=10.0 tests=AWL,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of misterpib@gmail.com designates 74.125.83.52 as permitted sender) Received: from [74.125.83.52] (HELO mail-gw0-f52.google.com) (74.125.83.52) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jun 2010 18:48:31 +0000 Received: by gwj23 with SMTP id 23so324043gwj.11 for ; Thu, 10 Jun 2010 11:48:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=CVTRNJi4RunBr8k1I7sBVzSUqmSd7hgfAtNdOx1k7jA=; b=xTeE5vaR6jlfwIVVnUAFR8OQd1k6TGQArlFeGshanE18CB4JrzgHk6y9N7n7mkP4y2 yWM5RPReQp0QfFKsIjiPsLlvrm1Ks53eiCuLK2xGoOjok6fQ4T/zYxDm7K2H6ydK72cI rHAsCqi8H1Yuu2t7qIuBXe1W2AcwjQC/Hmadk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=E7al6WrO2E/u36aqwaPmSbL7kKb8tFBil44IVDXNAk8PwKIr2DqD2UjZwosrIJPvOU fDODG5AtQK6M85srgvPSpi/rOWZpLdofHUu4nlSiDcGjwx0OzNNGl7ZuqBI5whgi1Tcu LOZF7GER29EbjQEPj4yNBKtgWBKSGBDIxLkNY= Received: by 10.229.85.14 with SMTP id m14mr570463qcl.140.1276195683688; Thu, 10 Jun 2010 11:48:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.142.10 with HTTP; Thu, 10 Jun 2010 11:47:42 -0700 (PDT) In-Reply-To: <06B9CE47-C36C-47DC-83FE-463455CD6E7B@gmail.com> References: <4C10F7E2.9080400@soartech.com> <06B9CE47-C36C-47DC-83FE-463455CD6E7B@gmail.com> From: Paul Bonser Date: Thu, 10 Jun 2010 13:47:42 -0500 Message-ID: Subject: Re: automatic timestamps To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=00163642749e63e1250488b176c6 --00163642749e63e1250488b176c6 Content-Type: text/plain; charset=ISO-8859-1 I'd say use both a document update handler and a document validation handler. That way, you enforce with the validation function that the format is the one you like, then in the update handler, you add the timestamp in that format. You will still be able to directly create a document without using the update handler, but it will be rejected if the format is incorrect. On Thu, Jun 10, 2010 at 9:35 AM, J Chris Anderson wrote: > > On Jun 10, 2010, at 7:34 AM, Laura Hamel wrote: > > > Hey Couch-Users! > > > > How do you guys handle timestamping documents? > > > > I have seen some advice to generate the timestamps in the application. > However, this has the drawback that multiple applications touching the same > database may generate inconsistent timestamps. Validation might be able to > reject updates when applications submit timestamps which are too > un-synchronized, but this seems like a weird way to solve the problem. I > found the documentation on using Document Update Handlers ( > http://wiki.apache.org/couchdb/Document_Update_Handlers) however these > have to be triggered separately. I'm also not clear on how to trigger that > update through jcouchdb. > > > > Is there a way to trigger the timestamp to be added automatically when > the document is created? > > > > The document update handler is the proper way to do this. We can't have > hooks on document create or update, because then the timestamp would get > changed every time the doc is replicated, as replication is just another > client. > > Chris > > > Thanks, > > Laura > > > > -- > > Laura Hamel > > Software Engineer > > Soar Technology > > lhamel@soartech.com > > > > -- Paul Bonser http://probablyprogramming.com --00163642749e63e1250488b176c6--