couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Jelsma <mar...@buyways.nl>
Subject Re: Validate uniqueness field
Date Tue, 30 Mar 2010 15:18:47 GMT
but that would not ensure uniqueness in some scenario's:

sha1(email_X + user_X) != sha1(email_X + user_Y)

using, separate documents is currently the only feasible method to ensure this 
kind of uniqueness.



On Tuesday 30 March 2010 17:14:27 Freddy Bowen wrote:
> I use a canonical sha1 hash of a JSON object within the doc as the _id to
>  ensure uniqueness in my app.
> 
> FB
> 
> 
> On Tue, Mar 30, 2010 at 11:05 AM, Markus Jelsma <markus@buyways.nl> wrote:
> Document ID's _must_ be a simple string. It would be nice though, to have
> complex ID's just as we can have complex keys for our views.
> 
> On Tuesday 30 March 2010 16:49:06 Andrew Melo wrote:
> > On Tue, Mar 30, 2010 at 9:44 AM, faust 1111 <faust451@gmail.com> wrote:
> > > Yes its only one way.
> > > Why couch don't implement uniqueness in simple way?
> >
> > It does implement it in a simple way. You get a unique field. Couch
> > makes sure that only one document has that field at a same time.
> >
> > Actually, I was just thinking, and someone else can correct me if I'm
> > wrong, but you may be able to do ['email','username'] as the _id.
> >
> > -Melo
> >
> > > 2010/3/30 Andrew Melo <andrew.melo@gmail.com>:
> > >> On Tue, Mar 30, 2010 at 9:13 AM, faust 1111 <faust451@gmail.com>
wrote:
> > >>> It's very frightful for me implement uniqueness in this way
> > >>> create doc for each uniq field and keep it in actual state when i
> > >>> update docs.
> > >>>
> > >>> may be better check uniqueness only in application layer?
> > >>> now i don't think about distribute.
> > >>
> > >> If you don't do it the way Jan suggested, you may end up with a race
> > >> condition, even if you don't distribute the database (i.e. if two
> > >> people register (nearly) simultaneously with the same username/email).
> > >> You would then have to support backing out/correcting any errors
> > >> manually in your application level code. If you're comfortable with
> > >> that, feel free, but Jan's way is much cleaner, in the long run.
> > >>
> > >> best,
> > >> Andrew
> > >>
> > >>> 2010/3/28 Jan Lehnardt <jan@apache.org>:
> > >>>> You need to have two documents with a unique ID each.
> > >>>>
> > >>>> Cheers
> > >>>> Jan
> > >>>> --
> > >>>>
> > >>>> On 27 Mar 2010, at 17:12, faust 1111 wrote:
> > >>>>> but what if i have two unique fields
> > >>>>>  login
> > >>>>>  email
> > >>>>>
> > >>>>> 2010/3/28 J Chris Anderson <jchris@gmail.com>:
> > >>>>>> On Mar 27, 2010, at 4:56 PM, faust 1111 wrote:
> > >>>>>>> Hi
> > >>>>>>>
> > >>>>>>> In what way i cat implement validation of uniqueness?
> > >>>>>>> User
> > >>>>>>>  email: unique
> > >>>>>>>  login:  unique
> > >>>>>>
> > >>>>>> You can only have 1 unique field per database. you implement
it by
> > >>>>>> using it as a docid, like
> > >>>>>>
> > >>>>>> {
> > >>>>>> "_id" : "user:unique",
> > >>>>>>   ...
> > >>>>>> }
> > >>>>>>
> > >>>>>> Chris
> > >>
> > >> --
> > >> --
> > >> Andrew Melo
> 
> Markus Jelsma - Technisch Architect - Buyways BV
> http://www.linkedin.com/in/markus17
> 050-8536620 / 06-50258350
> 

Markus Jelsma - Technisch Architect - Buyways BV
http://www.linkedin.com/in/markus17
050-8536620 / 06-50258350


Mime
View raw message