Adding id and author feilds via a update handler in Couchdb
===

How are people adding extra fields via the update handler in Couchdb ? I'd like to add the author ( I have a validation function to check the user is logged in) and the id added when a new documenter is created via an update handler.

The authors name is coming from req.userCtx.Name, the data I've sent is in req.body and I'm using the req.uuid as the _id

"updates": {
       "new": "function(doc,req) { var message = req.uuid; return [ { _id : req.uuid, "author" : req.userCtx.name, data : req.body}, message]}"
   }

Data been sent via a curl POST
cat test.json --> {"data" : {"name" : "myname","dob" : "myDOB"}}


This is how the data looks via the update handler 
{"_id":"a018fed749d64f5db754b39af803a88f","_rev":"1-939793c36d2bfe4de86f808fab056959","author":"admin","data":"{\"name\" : \"myname\",\"dob\" : \"myDOB\"}"}

If I do a standard POST ( not via an update handler ) it looks like this ..
{"_id":"a018fed749d64f5db754b39af803b621","_rev":"1-e44f0471e1df1018439fee3681b49547","data":{"name":"myname","dob":"myDOB"}}

What am I doing wrong ?



