couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From He Shiming <heshim...@gmail.com>
Subject Using document update handlers?
Date Mon, 20 Dec 2010 12:39:55 GMT
Dear CouchDB Community,

I'm reading http://wiki.apache.org/couchdb/Document_Update_Handlers
and I've got couple of questions.

1. I'm in need of updating documents without a prior readout to
determine its content and revisions. The task itself is similar to
UPDATE user SET password='x' WHERE user='id'; . I'm wondering if
update handlers are designed for this purpose?

2. I've got a update handler like this:
function(doc,req){
  if (!doc)
    return [null, 'fail-no-doc'];
  if (!req.query.id)
    return [null,'fail-no-id'];
  if (req.password)
    doc.password = req.password;
  return [doc,'success'];
}

I tried to call it this way: curl -d "id=docid&password=x"
http://localhost:5984/db/_design/user/_update/update_user . It always
return 'fail-no-doc'. I'm trying to use POST, and the wiki didn't
mention anything about how to set document id via POST parameter. How
do I manage to get this work, or should I just stick with PUT and send
parameters using URL?

Thanks!
-- 
Best regards,
He Shiming

Mime
View raw message