couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Itaboraí <>
Subject Re: Validate uniqueness field
Date Mon, 29 Mar 2010 23:35:56 GMT

I'm such a noobie!


On Mon, Mar 29, 2010 at 7:39 PM, Patrick Barnes <> wrote:

> To nitpick slightly - you won't get a value of zero, you'll just find that
> there is no entry for the given key. ;-)
> -Patrick
> On 30/03/2010 3:06 AM, "Daniel Itaboraí" <> wrote:
> Distributed uniqueness is a hard problem, but since you intend to use it
> only on a single node, perhaps you should create a view for each set of
> fields that you intend to be unique in your documents.You would emit the
> unique combination of values as the key and the document id as the value.
> For the reduce function, you should just count the number of documents that
> hold that particular key.
> Prior to each PUT or POST on a document, you should query the view to make
> sure that no other document has used that specific combination of values
> (the reduced value should be 0). Also, after each PUT or POST, you´d have
> to
> query it again to see if the uniqueness still holds (the reduced value
> should be 1).
> If the probability of two or more writers issuing operations that might
> violate the uniqueness constraint is low enough, you might be able to get
> away with it. This, of course, has a race condition (aside from also being
> slow, ugly and discouraged). You would have to periodically handle
> uniqueness violations either automatically or manually.
> I think you should ask yourself first what´s the worst that could happen
> when a violation of a uniqueness constraint happens. Sometimes you can just
> work around it.
> regards,
> Daniel Itaboraí
> On Sun, Mar 28, 2010 at 12:41 AM, faust 1111 <> wrote:
> > Why too documents?
> > Bu...

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