incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lance Carlson <lancecarl...@gmail.com>
Subject Re: CouchDB: Trouble with update handler
Date Mon, 29 Jul 2013 11:35:23 GMT
First, I'm not sure how you're making this design document, but you
should use a tool like Erica to help you stick functions in the right
place. You need to name your update handler something so that when you
curl or Ajax it, you reference the correct URL to handle it. When
you're done, the update URL should look something like this:

> https://zurv3aqzm.iriscouch.com/zzz/_design/mycouchapp/_update/task


Sent from my iPhone

On Jul 28, 2013, at 9:19 PM, Hank Knight <hknight555@gmail.com> wrote:

> My update handler is here: (please click on the link)
> https://zurv3aqzm.iriscouch.com/zzz/_design/_design/task
>
> {
>  updates: {
>    function (doc, req) {
>      doc.ts = 123;
>      doc.hello = 'world';
>      return [doc, toJSON(doc)];
>  }
> }
>
> When adding documents or updating documents, I want the value of
> "hello" to always be "world" and I want the value of "ts" to be 123.
>
> This is how I add a document:
>
> curl -X POST http://zurv3aqzm.iriscouch.com/zzz -d
> '{"_id":"1","user":"joe","fruit":"watermelon","type":"melons","ts":null,"hello":null}'
> -H "Content-Type: application/json"
>
> The values for "hello" and "ts" remain unchanged.
>
> What step am I missing or doing wrong?
>
> That database is live and available for testing.

Mime
View raw message