couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johannes J. Schmidt" <schm...@netzmerk.com>
Subject Re: can update function return doc?
Date Mon, 10 Oct 2011 06:53:54 GMT
You need to encode the response:

return [doc, toJSON(resp)]

g jo
Am Sonntag, den 09.10.2011, 18:10 -0700 schrieb bsquared:
> I am trying to get an update function to return the document as the
> response. 
> 
> This responds with error [1]. 
> 
> function (doc,req) {
>     
>     var docId = doc ? doc._id : req.uuid;
> 
>     if (!doc) {
> 	doc = {}; 
> 	doc._id = docId;
> 	doc.create_date = new Date ();
>       	doc.title = new Date ().toDateString ();
>     } 
> 
>     doc.last_change_date = new Date ();
> 
>     var resp =  {key : docId, value: doc};
>     return [doc, resp];
> }
> 
> [1] - {"error":"external_response_error","reason":"Invalid data from
> external server: {<<\"value\">>,\n {[{<<\"_id\">> ... 



Mime
View raw message