Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 22587 invoked from network); 30 Mar 2010 15:16:04 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Mar 2010 15:16:04 -0000 Received: (qmail 76109 invoked by uid 500); 30 Mar 2010 15:16:03 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 76027 invoked by uid 500); 30 Mar 2010 15:16:03 -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 76019 invoked by uid 99); 30 Mar 2010 15:16:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Mar 2010 15:16:03 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [195.85.130.166] (HELO smtp.atwork.nl) (195.85.130.166) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Mar 2010 15:15:55 +0000 Received: from localhost (localhost [127.0.0.1]) by smtp.atwork.nl (Postfix) with ESMTP id 95B9239C157 for ; Tue, 30 Mar 2010 17:15:35 +0200 (CEST) Received: from waldo.buyways.nl (atwork-154.r-212.178.116.atwork.nl [212.178.116.154]) by smtp.atwork.nl (Postfix) with ESMTP id 8AAF539C195 for ; Tue, 30 Mar 2010 17:15:23 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by waldo.buyways.nl (Postfix) with ESMTP id 36F843A1690 for ; Tue, 30 Mar 2010 17:15:23 +0200 (CEST) Received: from waldo.buyways.nl ([127.0.0.1]) by localhost (waldo.buyways.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5CwTBUFZPmzU for ; Tue, 30 Mar 2010 17:15:23 +0200 (CEST) Received: from zealand.localnet (beauregard.buyways.nl [192.168.217.1]) by waldo.buyways.nl (Postfix) with ESMTP id 136253A168F for ; Tue, 30 Mar 2010 17:15:23 +0200 (CEST) From: Markus Jelsma Reply-To: markus@buyways.nl Organization: Buyways To: user@couchdb.apache.org Subject: Re: Validate uniqueness field Date: Tue, 30 Mar 2010 17:15:15 +0200 User-Agent: KMail/1.12.2 (Linux/2.6.31-20-generic; KDE/4.3.2; i686; ; ) References: <201003301705.16011.markus@buyways.nl> In-Reply-To: <201003301705.16011.markus@buyways.nl> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201003301715.15849.markus@buyways.nl> X-Virus-Scanned: by @Work X-Virus-Checked: Checked by ClamAV on apache.org Perhaps i sent the e-mail a bit too fast because issues would surface if couch allows complex ID's. For example, would the entire value of the key be considered to be unique, or would the individual elements? And what about the order of the values inside the key? ["user_1", "email_1"] vs. ["email_1", "user_1"] or ["user_1", "email_2"] vs. ["email_2", "user_1"] The problem is that this the answer to this question, i believe, depends on your usecase. Also, the current source might not that easily be patched for such a feature, if it would be a good idea at all to support such a feature. On Tuesday 30 March 2010 17:05:15 Markus Jelsma 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 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 : > > >> On Tue, Mar 30, 2010 at 9:13 AM, faust 1111 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 : > > >>>> 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 : > > >>>>>> 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