Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D931DCBBD for ; Mon, 29 Jul 2013 11:35:58 +0000 (UTC) Received: (qmail 16710 invoked by uid 500); 29 Jul 2013 11:35:57 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 16359 invoked by uid 500); 29 Jul 2013 11:35:53 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 16349 invoked by uid 99); 29 Jul 2013 11:35:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Jul 2013 11:35:51 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lancecarlson@gmail.com designates 209.85.214.169 as permitted sender) Received: from [209.85.214.169] (HELO mail-ob0-f169.google.com) (209.85.214.169) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Jul 2013 11:35:46 +0000 Received: by mail-ob0-f169.google.com with SMTP id wc20so2759350obb.28 for ; Mon, 29 Jul 2013 04:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:from:in-reply-to:mime-version:date:message-id:subject:to :content-type; bh=9Noc5LjEDeLlpPgTBEFNt0OJBOfW6zlzx9gJxeZ3TU0=; b=gn3uLCktOY+EC2vtAdFkWlN4lIuinjqxJWmCCj178oLIW4RxduTE8JojO8h2gRhQBR 83xdsW9HgjM9YUrsMytcU7Q5DRrYFtWbHigq5rq5RWCIt08ErW8EWNAGM64d0c8mHT9o 25D5kHtK7qiFtet6q/ZAvmRu9b0fpBTGzT8aZjWKAuzhaqSyJtiF5ud/Ix+3pO9SKdK/ 8D5SbRbyPUHN6GK3SgUWwq10Y9Er17sIq04iv3eEkmhM+RtCkLqOhQondas3pHz222MB /uWMYl10masvoBlB3vyIp60o3R6kKgSEItYK6nalWtX5PCjKjtpPp7fBuljUAK0EdMxL mTTw== X-Received: by 10.50.79.167 with SMTP id k7mr942019igx.56.1375097724042; Mon, 29 Jul 2013 04:35:24 -0700 (PDT) References: From: Lance Carlson In-Reply-To: Mime-Version: 1.0 (1.0) Date: Mon, 29 Jul 2013 07:35:23 -0400 Message-ID: <1762485917923350887@unknownmsgid> Subject: Re: CouchDB: Trouble with update handler To: "user@couchdb.apache.org" Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org 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 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.