incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <rnew...@apache.org>
Subject Re: update handler that insert a new document
Date Tue, 26 Feb 2013 13:24:32 GMT
Works for me;

➜  update_1.2.1  curl
localhost:5984/db1/_design/update_1.2.1/_update/foo -d
'{"UniqueID":"foo"}'
{"UniqueID":"foo","_id":"foo","timestamp":1361884870867}%
➜  update_1.2.1  curl localhost:5984/db1/foo
{"_id":"foo","_rev":"1-2af73253e00eada9e39a7519804f5574","UniqueID":"foo","timestamp":1361884870867}
➜  update_1.2.1

1.2.1 is just a few security fixes over 1.2.0, nothing else really changed.

Also, req.uuid contains a server generated uuid for your convenience.

B.



On 26 February 2013 12:19, Dominic Laflamme
<Dominic.Laflamme@autodesk.com> wrote:
> Hello list,
> I've been using and update handler which inserts new documents after time-stamping them.
I am following the documentation found here:
>
> http://wiki.apache.org/couchdb/Document_Update_Handlers
>
> I've been using the following update handler successfully with 0.10.0 and 1.2.0 on Ubuntu
and Windows, but I just updated to 1.2.1 and this particular handler now fails with the error
"bad return value".
>
> function(doc,req) {
> var data = JSON.parse(req.body);
> data['_id'] = data.UniqueID;
> if ( data.timestamp == null )
> {
> data.timestamp = new Date().getTime();
> }
> return [ data, JSON.stringify(data)];
> }
>
> Does anybody have insight on what causes the problem? Is it still "legal" to add new
documents using update handlers?
>
> Regards,
> -Dominic
>
>
>

Mime
View raw message