couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Le Brasseur <>
Subject Document update handlers: Examples
Date Thu, 10 Aug 2017 11:12:10 GMT
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 examples please.

Many thanks.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message