Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 70798 invoked from network); 11 Nov 2010 22:45:46 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Nov 2010 22:45:46 -0000 Received: (qmail 59563 invoked by uid 500); 11 Nov 2010 22:46:16 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 59524 invoked by uid 500); 11 Nov 2010 22:46:16 -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 59510 invoked by uid 99); 11 Nov 2010 22:46:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Nov 2010 22:46:16 +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 (athena.apache.org: domain of zachary.zolton@gmail.com designates 74.125.82.180 as permitted sender) Received: from [74.125.82.180] (HELO mail-wy0-f180.google.com) (74.125.82.180) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Nov 2010 22:46:11 +0000 Received: by wyb29 with SMTP id 29so679858wyb.11 for ; Thu, 11 Nov 2010 14:45:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=BdUB6G4IBzIcjkYnjgw7imt7clPK9gdI/pkgzyLCP24=; b=Wq0z6mL0f1ZjEk6S81yyfyYE1PdKpGwpbqbnbvwFJD7/FxwSpcE/Ui2vyxWjzFzSZY OHSLIkrUTcjcpl0vdLbecaYMlYtUR5aZ69DPmLh4NgrDPEQnnHkCOkmeGiB3zzffcDws NEe2kiRPk5FqLxADcVOwey2nBbAu8fyQAWA+w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=HkvOZbV8aHxeCj6+iirxw2Ma9kcFUzc3we35rEr3VuD45HvcDhdv80Vl8wqtoLBJrl I+uFDkqJ447EQ22uEo5Bv+NDDoMggqw9umcMDWIiRfYvIgpIgCIoCQkWumX3iF9L9O8a 1sjreB5nQX4OmaxN5zgHkQHUWiOcetNeOSa9s= Received: by 10.227.153.199 with SMTP id l7mr1492332wbw.133.1289515548290; Thu, 11 Nov 2010 14:45:48 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.69.2 with HTTP; Thu, 11 Nov 2010 14:45:28 -0800 (PST) In-Reply-To: References: From: Zachary Zolton Date: Thu, 11 Nov 2010 16:45:28 -0600 Message-ID: Subject: Re: Update handler doc ids To: user@couchdb.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable I didn't realize that the docs you were trying to update represent a user! Yes, by all means, use their username in the doc ID. Then you wont need to do a query just to determine the ID. If you're considering having other types of docs in the same DB, however, you'll probably wanna namespace the user doc IDs. For example, user "foobar" has a doc such as "user:foobar". =97Zach On Thu, Nov 11, 2010 at 2:00 PM, Wordit Ltd wrote= : > 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 wr= ote: >>> 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=3Dx >>> >>> Marcus >>> >> >