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 7E23B1034F for ; Wed, 20 Nov 2013 07:46:35 +0000 (UTC) Received: (qmail 18356 invoked by uid 500); 20 Nov 2013 07:46:34 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 18151 invoked by uid 500); 20 Nov 2013 07:46:33 -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 18143 invoked by uid 99); 20 Nov 2013 07:46:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Nov 2013 07:46:33 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [209.85.216.171] (HELO mail-qc0-f171.google.com) (209.85.216.171) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Nov 2013 07:46:28 +0000 Received: by mail-qc0-f171.google.com with SMTP id s13so5525651qcv.16 for ; Tue, 19 Nov 2013 23:46:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type; bh=hOcYoxYTqZ5alMM/4hhPM8LE0Ucmz6QRZakOKO1WFMw=; b=k7PfYCl5g0eFiHycy2xpxGP4E42H/0oLmiBN28ZqCkz/NUKKu1g9XJZlgFIU5nU96J cpUVAzD+Ww6Yjn1SGuG0farlgLSPh3wQZA68KPf3hnkQFSxAEoCbnYQqXq/7la9QYED4 jenDDF7zm+l9D/2D7vU/KmuShyP9IqPoSOg9iPNAHmm0gmX75ycrzfzdcCElyBqySudW xSE6k2DmQWCdJeYTfaFv1xeKzuXFc0xPrJAJZaT42ZxMUCYWz4/yVb36VJZWXULXjOYy XSwNTQXj7/IVT4OT0NKj05P4Szo32E9k5rWetrQh0u6aGYz2lGJGaoPjxDUQ8Q7j8nJK CHog== X-Gm-Message-State: ALoCoQmIGko73XBC812ehqxetHKmy/qxClyA9RPGpoisS251m8Mo0Cr5scOPZ6z0uKD30rYVeKK9 X-Received: by 10.49.1.106 with SMTP id 10mr26456590qel.55.1384933567437; Tue, 19 Nov 2013 23:46:07 -0800 (PST) Received: from [192.168.11.13] (c-68-37-177-195.hsd1.nj.comcast.net. [68.37.177.195]) by mx.google.com with ESMTPSA id a5sm61796239qae.2.2013.11.19.23.46.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Nov 2013 23:46:06 -0800 (PST) Message-ID: <528C68BE.6020106@orgmeta.com> Date: Wed, 20 Nov 2013 02:46:06 -0500 From: Vivek Pathak User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: user@couchdb.apache.org Subject: Re: simultaneously run update handler and update doc content References: <528C5623.8000405@orgmeta.com> <528C676A.9020606@orgmeta.com> In-Reply-To: <528C676A.9020606@orgmeta.com> Content-Type: multipart/alternative; boundary="------------010102060800080608000507" X-Virus-Checked: Checked by ClamAV on apache.org --------------010102060800080608000507 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 11/20/2013 02:40 AM, Vivek Pathak wrote: > > I have an update handler. > |{ > "|_id|":|"_design/compnbd"|, > "|_rev|":|"36-3321da9588a5a7b3fef8789bdfefe18d"|, > "|updates|":|{ > "|timestamp|":|"function(doc, req) {\n if( doc.type == \"profile\" ) { \n var d = new Date();\n doc.serverISO8601time = d.toISOString(); \n doc.serverTime = d.getTime() / 1000 ;\n }\n return [doc , ''] ;\n} \n"| > }|, > "|language|":|"javascript"|, > "|views|":|{ > // removed ... > } > } > || > > The function is copied here for convenience: > function(doc, req) { > if( doc.type == "profile" ) { > var d = new Date(); > doc.serverISO8601time = d.toISOString(); > doc.serverTime = d.getTime() / 1000 ; > } > return [doc , ''] ; The return is an array of doc and empty string (empty string was messed up in copy paste to email) - but the same behavior happens if it were "OK" > } > > > I run the following commands: > > curl -s 'http://localhost:5984/i7rmdb/testid' > /tmp/2.json > > cat /tmp/2.json > {"_id":"testid","_rev":"5-71ee77bc43fc698a935abc60dc33a82c","type":"profile","text":"hello 123","serverISO8601time":"2013-11-20T07:29:35.497Z","serverTime":1384932575.496999979} > > Now I edit the document. > > cat /tmp/2.json > {"_id":"testid","_rev":"5-71ee77bc43fc698a935abc60dc33a82c","type":"profile","text":"hello > 12345 !!!! text changed .... > ","serverISO8601time":"2013-11-20T07:29:35.497Z","serverTime":1384932575.496999979} > > And put it using the update handler. > > curl -s -X PUT > 'http://localhost:5984/i7rmdb/_design/compnbd/_update/timestamp/testid' -d > @/tmp/2.json > > Notice the text did not change, just the time stamp changed. > > curl -s 'http://localhost:5984/i7rmdb/testid' > {"_id":"testid","_rev":"6-6726469319fc80710ef15d0df6dd6320","type":"profile","text":"hello123","serverISO8601time":"2013-11-20T07:31:58.351Z","serverTime":1384932718.3510000706} > > > I was expecting both text and timestamp to change. Is that correct? > > Thanks > > > On 11/20/2013 01:38 AM, Stanley Iriele wrote: >> Are you asking how to update a document with an update handler? Like...what >> the pattern looks like? >> On Nov 19, 2013 10:31 PM, "Alexander Shorin" wrote: >> >>> The update handlers does document update already with single http >>> request. To update document content or not is the question of function >>> implementation. >>> -- >>> ,,,^..^,,, >>> >>> >>> On Wed, Nov 20, 2013 at 10:26 AM, Vivek Pathak >>> wrote: >>>> Hi >>>> >>>> I have couchdb 1.2.1 - and wanted to update document content and also >>> run a >>>> update handler using only one http call. >>>> >>>> Is it possible to do this? >>>> >>>> Thanks >>>> Vivek >>>> > --------------010102060800080608000507--