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 <[email protected]> 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 <[email protected]> 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 >> >
