couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cory Nelson <phro...@gmail.com>
Subject Ensuring unique attributes across documents?
Date Thu, 12 Nov 2009 01:00:34 GMT
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

Mime
View raw message