From user-return-2875-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Sun Jan 11 23:30:38 2009 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 6934 invoked from network); 11 Jan 2009 23:30:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Jan 2009 23:30:37 -0000 Received: (qmail 61200 invoked by uid 500); 11 Jan 2009 23:30:36 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 61162 invoked by uid 500); 11 Jan 2009 23:30:36 -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 61151 invoked by uid 99); 11 Jan 2009 23:30:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jan 2009 15:30:36 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of thesunny@gmail.com designates 209.85.198.228 as permitted sender) Received: from [209.85.198.228] (HELO rv-out-0506.google.com) (209.85.198.228) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jan 2009 23:30:29 +0000 Received: by rv-out-0506.google.com with SMTP id g37so10301776rvb.35 for ; Sun, 11 Jan 2009 15:30:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=+wdKD1YOvMsDPymqUTsHx+9o1+Z9AjLDdth/HKGHqjg=; b=tP2IVPJamlRYkeVQJYykx7oS9WvhyvV8oRtLsfXfw+UPMENnCzmQwFCKN88rpuzaxh IPJbtL+BDgQO8Aw62fv6Xz/lK4X2tJfeQzxvli4OYfm3ShWV9CQ2g+OQswWzQsMyYVrd DgCSPsLB9hNo28SwhaOqYHMUfZKUSMdi3tD4Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=shT52JxzFOL5/ttuWmkJtiKpkYObd0tjGInwNJlT7FlmIQf6ooUOGESX1TjPbofoIT cf7pkfrkucAjn8FJwbN8WG/KOgj4PiWWP6byeZ/q6PaQ/jlUeHTQxFJ7MLDZJ1gH9YPr bEgnYdRd9G7yqTAkcJWWv0Nqnzo/DnCZE4D0U= Received: by 10.141.162.5 with SMTP id p5mr14056152rvo.193.1231716609655; Sun, 11 Jan 2009 15:30:09 -0800 (PST) Received: by 10.140.144.20 with HTTP; Sun, 11 Jan 2009 15:30:09 -0800 (PST) Message-ID: <518815b70901111530o23f6ce31yb40f974ea85467c0@mail.gmail.com> Date: Sun, 11 Jan 2009 15:30:09 -0800 From: "Sunny Hirai" To: user@couchdb.apache.org Subject: Can I guarantee uniqueness in a field without using _id? MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_222315_14418588.1231716609644" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_222315_14418588.1231716609644 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline First of all, I'd like to say that CouchDB is an amazing project. I've been following it for a year and have recently made it a first class citizen of my framework. Anyways, looked for this answer but I couldn't find it. Let's say I want to create a database that contains the pages in a wiki. Each document looks something like this: { name: 'about_us', body: 'This is the about us page' } There would be a view on the database where the key is 'name'. The problem is this: User A goes to create the 'aboutus' page. We want it to be unique so we check if it is in the view. Since it is the first 'about_us' page, we can't find it. So we are about to do the insert but haven't started yet. In the meantime, User B goes to create the 'aboutus' page. We check the view and it also isn't there yet because User A has not completed its insert. We start to do the insert for User B. In this case, both User A and User B have begun the insert process. At the end of the inserts, we will have two documents with the same name 'aboutus'. Can this be prevented? I know I can put the 'name' in the '_id' field but I'd like to avoid it because I'm abstracting CouchDB and the abstraction does not allow for it. Anybody have any solutions other than making 'name' the '_id' field? -Sunny ------=_Part_222315_14418588.1231716609644--