Following: CouchDB Document Update Handlers (in-place updates) and http://wiki.apache.org/couchdb/Document_Update_Handlers
I'm trying to create my own function which increment an integer for now, but I'm getting:
{"error":"bad_request","reason":"Attachment name can't start with '_'"}
My design document looks like: _design/db
"check": {
"increment": "function(doc,req){ var channel = req.query.channel; doc.channels[0].sp = doc.channels[0].sp+1; return[channel, 'check']}"
}
And the request is like:
curl -X PUT https://server/db/_design/db/_check/increment/channels?channel=foo
I don't understand very well what I'm doing wrong, if I remove the '_' I will get:
{"error":"conflict","reason":"Document update conflict."}
Thanks