incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Bonser <mister...@gmail.com>
Subject Re: automatic timestamps
Date Thu, 10 Jun 2010 18:47:42 GMT
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 <jchris@gmail.com> 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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message