Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 45217 invoked from network); 12 Nov 2009 01:00:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 12 Nov 2009 01:00:58 -0000 Received: (qmail 22196 invoked by uid 500); 12 Nov 2009 01:00:57 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 22130 invoked by uid 500); 12 Nov 2009 01:00:57 -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 22113 invoked by uid 99); 12 Nov 2009 01:00:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Nov 2009 01:00:57 +0000 X-ASF-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of phrosty@gmail.com designates 209.85.216.186 as permitted sender) Received: from [209.85.216.186] (HELO mail-px0-f186.google.com) (209.85.216.186) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Nov 2009 01:00:54 +0000 Received: by pxi16 with SMTP id 16so1216101pxi.29 for ; Wed, 11 Nov 2009 17:00:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=AlEb3sPTYKqBMi28Jkwz66/7BS+N22tzCgcExI7eksY=; b=v5UE4koSlGygaECYQJ8nDayXyZqdH6DNHTsk6hDeKzGG3GMBnZzHt8mOIuJ1LwZiIn dLg8wSuhKj6i1t3sODV84uvBpj3KQi8arypDc3Y5xyBXRZsMmQ4icn+8J6CTLYRNZd70 VZ5AX0fyJF0XIa9wC8+S4PQQpUp0kOOLbXsQo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=Tp41YidHN3icYoduqlAFyofOrUlQwYbxZADx5vhWvnik3lCSxE3XN0ckrLc5o8MJZZ aBXAWE+IGJrPMzSuOXKKSE2TOkhm1kpKuCbcMiCKan7RojWQg9xtOYLsqiOrsfT24kTI ilvpmFRsSD4g6bdbxq2WmuIP2CXrBV/W2FF00= MIME-Version: 1.0 Received: by 10.142.3.3 with SMTP id 3mr238553wfc.275.1257987634603; Wed, 11 Nov 2009 17:00:34 -0800 (PST) Date: Wed, 11 Nov 2009 17:00:34 -0800 Message-ID: <9b1d06140911111700k43d3f23eob40bf63fd1d43521@mail.gmail.com> Subject: Ensuring unique attributes across documents? From: Cory Nelson To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 Hello, I'm trying to implement a typical user signup operation: when you finally add a user to the database, you want it to have both a unique user name, and a unique email. In SQL I'd do something like: BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE count = SELECT COUNT(*) FROM t_users WHERE name=? OR email=? if(count == 0) { INSERT INTO t_users VALUES(...) COMMIT } else { ROLLBACK } Can anyone give an example of how to achieve the same thing in CouchDB? -- Cory Nelson