Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 91063 invoked from network); 11 Nov 2010 20:01:05 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Nov 2010 20:01:05 -0000 Received: (qmail 65422 invoked by uid 500); 11 Nov 2010 20:01:32 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 65383 invoked by uid 500); 11 Nov 2010 20:01:32 -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 65375 invoked by uid 99); 11 Nov 2010 20:01:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Nov 2010 20:01:32 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of wordituk@googlemail.com designates 209.85.213.180 as permitted sender) Received: from [209.85.213.180] (HELO mail-yx0-f180.google.com) (209.85.213.180) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Nov 2010 20:01:26 +0000 Received: by yxm8 with SMTP id 8so27141yxm.11 for ; Thu, 11 Nov 2010 12:01:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=/i2HJOlJJNRy9M6upNN1yq907Sycw1yDf/aEHrdStU0=; b=aUXIbPaGTjBiCfU6U88NIzfsiAh01YkkLdAHeb0/tdIS0M+miLNjMyWbM22IE5vanm NDapzdXK1TZnUBjLl7VTxzEbqD5jrZin9FMMjHLlxSVmy0jsd1vjDIEWljmUyYoaucGY pUE+RJ60ch7j2oHj/XbauTZhRAAyd/ehbWTCk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=J9SxD96ivg9derQFjsXKMql/ktfCxgRIayJCWwV914EFkDolw1PTxA3D85MyOP1Rwb 5dcoZJzfhGaXcP/5yQyAO6eVi1OsMuc0daLpGmN1+LkHGQ0c2fUdq46Mntpl9tvH05DV oN7k30QgAWkagCdRJYcqH4oFHUSPhTau70kRk= Received: by 10.91.143.17 with SMTP id v17mr1908560agn.136.1289505665167; Thu, 11 Nov 2010 12:01:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.90.14.12 with HTTP; Thu, 11 Nov 2010 12:00:45 -0800 (PST) In-Reply-To: References: From: Wordit Ltd Date: Thu, 11 Nov 2010 21:00:45 +0100 Message-ID: Subject: Re: Update handler doc ids To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org Zach, Thanks for the confirmation on the doc ID. I need to update a doc belonging to the logged in user. If I use a field like "owner": "username" then I would need to find the doc ID first. Don't you lose the advantage of an update handler by first doing a read request? I mean you might as well do a standard read then a write. Two calls. Update handlers have the advantage of a single db call, or not? To use an update handler, I need the ID. I figured that if I set the doc ID to be the username, which is unique, then I can send the username as the doc ID to the update handler. Is there anything wrong with that approach? Marcus On Thu, Nov 11, 2010 at 8:45 PM, Zachary Zolton wrote: > > Update handlers can't query the database nor access external > resources. They just update or create a single document based on the > HTTP request (and the current document object, in the case of updating > an existing document). > > Moreover, if you want to update a document, you'll need to provide the > ID. So, you can either construct the ID from variables available at > that point in your program, or make a query to find the doc ID before > calling your update handler. > > Give this a read: > http://wiki.apache.org/couchdb/Document_Update_Handlers > > If you provide more background about your scenario, I can give you > more explicit advice. > > > Cheers, > > Zach > > > On Thu, Nov 11, 2010 at 8:59 AM, Wordit Ltd wrote: >> Do update handlers require the doc id, or is it possible to search for >> the doc as with views? >> >> I need to update the document belonging to the logged in user. (I'll >> use a validation function to check that.) >> The only workaround I could think of is using the username as the doc >> id. Then I call the update handler with .../handler/username?param=x >> >> Marcus >> >