From user-return-10291-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Tue Apr 27 13:59:01 2010 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 41839 invoked from network); 27 Apr 2010 13:59:01 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 27 Apr 2010 13:59:01 -0000 Received: (qmail 74007 invoked by uid 500); 27 Apr 2010 13:58:59 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 73963 invoked by uid 500); 27 Apr 2010 13:58:59 -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 73955 invoked by uid 99); 27 Apr 2010 13:58:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Apr 2010 13:58:59 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of koeberle@gmail.com designates 209.85.218.221 as permitted sender) Received: from [209.85.218.221] (HELO mail-bw0-f221.google.com) (209.85.218.221) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Apr 2010 13:58:51 +0000 Received: by bwz21 with SMTP id 21so12373037bwz.35 for ; Tue, 27 Apr 2010 06:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=hMjBKjEzOeSYI6Q4JnxfuY4wXmdBvp01I+fqLU1V4/k=; b=fyQVwzth7zBdOfqhqo7i719dYnPFuS0UcZgv4PD/wrpenF6RJC8+F28nIqQCYhttwN JxC9BWizihCpZqeMcJVG++DndSanRwHq25z7yZPOKjPchENBdP20t+doJzgm+JGTynJi IWb7UzBKgfJKFfCeQNQ9DVn9rZX59eGYZfW68= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=fd6mKqo0MuWknfz7/4n4SBaLGTEf7njAAhEZXFNuLqS6GT0JBly5FPOHUQUIUXA01Y aeMUVwGOxuaaDqfBXGp3SgzdJS19RRx1jbH/bHfA0LqRsDGJEkHHvs38Mnk1sBs4wX/B Dzs4zy1coWQEcQcqt1C5qhKh2vfkZKwAIyEeg= MIME-Version: 1.0 Received: by 10.204.155.68 with SMTP id r4mr3674229bkw.208.1272376709873; Tue, 27 Apr 2010 06:58:29 -0700 (PDT) Received: by 10.204.54.208 with HTTP; Tue, 27 Apr 2010 06:58:29 -0700 (PDT) In-Reply-To: References: <28B4793B-46E8-43B2-82BF-BDCD3BCDAD1E@googlemail.com> Date: Tue, 27 Apr 2010 15:58:29 +0200 Message-ID: Subject: Re: How to change JSON before storing From: =?ISO-8859-1?Q?Andreas_K=F6berle?= To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Ok there was an error in my design doc now it looks like: { "_id": "_design/yslow", "_rev": "12-ad0d504e48808ef5643545e3817a62f8", "updates": { "addDate": "function(doc, req){doc.date =3D new Date(); return[doc,r= eq]}" } } And I got another error: JavaScript function raised error: TypeError: doc is null. Normal saving the json in http://exeter:5984/yslow works well by the way. On 27 April 2010 15:17, Andreas K=F6berle wrote: > Mhmm it seems that POST work, but now I get another quirk. > > this is my design doc: > { > =A0 "_id": "_design/yslow", > =A0 "_rev": "9-a4ece33bca6f678cf1752907bfe8596c", > =A0 "updates": "{'addDate' : 'function(doc, req){doc.date =3D new Date(); > return[doc,req]}'}" > } > > this is my url: > http://exeter:5984/yslow/_design/yslow/_update/addDate > > this is the json that YSLOW sends: > > var a =3D {"w":41480,"o":93,"u":"http%3A%2F%2Fwww.google.com%2Fsearch%3Fi= e%3DUTF-8%26oe%3DUTF-8%26sourceid%3Dnavclient%26gfns%3D1%26q%3Dyslow%2Bbeac= on%2Bcouchdb","r":6,"s":"","i":"ydefault","lt":582,"comps":[ > =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"type":"doc", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"url":"http%3A%2F%2Fwww.google.com%2Fsearc= h%3Fie%3DUTF-8%26oe%3DUTF-8%26sourceid%3Dnavclient%26gfns%3D1%26q%3Dyslow%2= Bbeacon%2Bcouchdb", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"size":31534, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"resp":226, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"gzip":8407, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"cr":481 > =A0 =A0 =A0 =A0}, > =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"type":"js", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"url":"http%3A%2F%2Fwww.google.com%2Fexter= n_js%2Ff%2FCgJkZSswCjhjQB0sKzAOOA0sKzAWOBcsKzAXOAYsKzAYOAUsKzAZOBwsKzAhODVA= ASwrMCU4yogBLCswJjgKLCswJzgELCswKjgELCswKzgMLCswPDgCLCswQDgPLCswRTgBLCswTjg= ELCswUTgALIACDQ%2FKQlSo2GWluY.js", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"size":57272, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"resp":24, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"gzip":"21189", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"expires":"2011/4/26" > =A0 =A0 =A0 =A0}, > =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"type":"cssimage", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"url":"http%3A%2F%2Fwww.google.com%2Fimage= s%2Fnav_logo8.png", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"size":5656, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"resp":24, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"expires":"2010/4/27" > =A0 =A0 =A0 =A0}, > =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"type":"image", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"url":"http%3A%2F%2Fwww.google.com%2Fimage= s%2Ficons%2Fsearch-16.gif", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"size":1005, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"resp":23, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"expires":"2010/4/27" > =A0 =A0 =A0 =A0}, > =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"type":"image", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"url":"http%3A%2F%2Fwww.google.com%2Fimage= s%2Fswxa.gif", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"size":5223, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"resp":22, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"expires":"2010/4/27" > =A0 =A0 =A0 =A0}, > =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"type":"doc", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"url":"http%3A%2F%2Fclients1.google.com%2F= generate_204", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"size":0, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"resp":null > =A0 =A0 =A0 =A0} > ]} > > and this is the error I've got: > > 1> [debug] [<0.11411.0>] OAuth Params: [] > 1> [debug] [<0.11411.0>] Minor error in HTTP request: {not_found,json_mis= match} > 1> [debug] [<0.11411.0>] Stacktrace: [{couch_util,get_nested_json_value,2= }, > =A0 =A0 =A0 =A0 =A0 =A0 {couch_httpd_show,handle_doc_update_req,2}, > =A0 =A0 =A0 =A0 =A0 =A0 {couch_httpd_db,do_db_req,2}, > =A0 =A0 =A0 =A0 =A0 =A0 {couch_httpd,handle_request,5}, > =A0 =A0 =A0 =A0 =A0 =A0 {mochiweb_http,headers,5}, > =A0 =A0 =A0 =A0 =A0 =A0 {proc_lib,init_p_do_apply,3}] > 1> [debug] [<0.11411.0>] httpd 404 error response: > =A0{"error":"not_found","reason":"json_mismatch"} > > > On 27 April 2010 14:48, Adam Kocoloski wrote: >> No, validation functions cannot modify documents. =A0The usual reason gi= ven is that they run during replication as well as during client updates. >> >> Adam >> >> On Apr 27, 2010, at 8:40 AM, Andreas K=F6berle wrote: >> >>> Unfortunately _updates doesn't work for me cause YSLOW send with POST >>> and I get a "Only DELETE,GET,HEAD,PUT allowed" error. Could I use >>> validate_doc_update instead? >>> >>> >>> On 27 April 2010 14:12, Adam Kocoloski wrote: >>>> That's correct, Simon, _update handlers don't work with _bulk_docs tod= ay. =A0Best, >>>> >>>> Adam >>>> >>>> On Apr 27, 2010, at 8:07 AM, Simon Metson wrote: >>>> >>>>> Hi, >>>>> =A0 =A0 =A0 Is it possible to apply an update function to a bulk inse= rt? From reading that page it sounds like not... >>>>> Cheers >>>>> Simon >>>>> >>>>> On 27 Apr 2010, at 11:05, Sebastian Cohnen wrote: >>>>> >>>>>> The answer is yes, to make it short :) >>>>>> >>>>>> http://wiki.apache.org/couchdb/Document_Update_Handlers >>>>>> >>>>>> >>>>>> On 27.04.2010, at 11:56, Andreas K=F6berle wrote: >>>>>> >>>>>>> Is there a way to add data to a JSON Object with couchdb, before >>>>>>> storing it. I've got data direct from YSlow firefox extension but >>>>>>> unfortunately without a timestamp. >>>>>> >>>>> >>>> >>>> >> >> >