Hi.
I am trying to create a generic document update handler.

I am using:

function(doc, req) {var field = req.query.field;  var value =
req.query.value; var message = 'set '+field+' to '+value;  doc[field] =
value; return [doc, message];  }

This works ok with simple json but not with a nested object such as
"abc":{"ax":"one", "by":"two" ...}

my curl command is:

curl -X PUT '
http://127.0.0.1:5984/db/_design/updatehandler/_update/inplace/id?field=abc.ax&value=three
'

The result is a new field is created and the existing abc:{ax:one} is left
untouched.


With a simpler example:

if I have: "xyz":"five"

curl -X PUT '
http://127.0.0.1:5984/db/_design/updatehandler/_update/inplace/id?field=xyz&value=ten
'

... works correctly.

I have not yet tried the generic process on "pqr":[s, t, u] yet but I guess
this may require a different design modification as well.

Ideally one wants something that works in at least the abovementioned three
cases if possible, as long as it is not too complex for it not to be worth
the effort.

Could someone possibly kindly help here or refer me to some examples please.

Many thanks.


John

Reply via email to