Document Update Handlers CouchDB Javascript

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 '' 

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

With a simpler example:

if I have: "xyz":"five"

curl -X PUT '' 

… 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 javascript examples please.

Many thanks.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.