couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Köberle <koebe...@gmail.com>
Subject Re: How to change JSON before storing
Date Tue, 27 Apr 2010 13:17:54 GMT
Mhmm it seems that POST work, but now I get another quirk.

this is my design doc:
{
   "_id": "_design/yslow",
   "_rev": "9-a4ece33bca6f678cf1752907bfe8596c",
   "updates": "{'addDate' : 'function(doc, req){doc.date = 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 = {"w":41480,"o":93,"u":"http%3A%2F%2Fwww.google.com%2Fsearch%3Fie%3DUTF-8%26oe%3DUTF-8%26sourceid%3Dnavclient%26gfns%3D1%26q%3Dyslow%2Bbeacon%2Bcouchdb","r":6,"s":"","i":"ydefault","lt":582,"comps":[
	{
		"type":"doc",
		"url":"http%3A%2F%2Fwww.google.com%2Fsearch%3Fie%3DUTF-8%26oe%3DUTF-8%26sourceid%3Dnavclient%26gfns%3D1%26q%3Dyslow%2Bbeacon%2Bcouchdb",
		"size":31534,
		"resp":226,
		"gzip":8407,
		"cr":481
	},
	{
		"type":"js",
		"url":"http%3A%2F%2Fwww.google.com%2Fextern_js%2Ff%2FCgJkZSswCjhjQB0sKzAOOA0sKzAWOBcsKzAXOAYsKzAYOAUsKzAZOBwsKzAhODVAASwrMCU4yogBLCswJjgKLCswJzgELCswKjgELCswKzgMLCswPDgCLCswQDgPLCswRTgBLCswTjgELCswUTgALIACDQ%2FKQlSo2GWluY.js",
		"size":57272,
		"resp":24,
		"gzip":"21189",
		"expires":"2011/4/26"
	},
	{
		"type":"cssimage",
		"url":"http%3A%2F%2Fwww.google.com%2Fimages%2Fnav_logo8.png",
		"size":5656,
		"resp":24,
		"expires":"2010/4/27"
	},
	{
		"type":"image",
		"url":"http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fsearch-16.gif",
		"size":1005,
		"resp":23,
		"expires":"2010/4/27"
	},
	{
		"type":"image",
		"url":"http%3A%2F%2Fwww.google.com%2Fimages%2Fswxa.gif",
		"size":5223,
		"resp":22,
		"expires":"2010/4/27"
	},
	{
		"type":"doc",
		"url":"http%3A%2F%2Fclients1.google.com%2Fgenerate_204",
		"size":0,
		"resp":null
	}
]}

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_mismatch}
1> [debug] [<0.11411.0>] Stacktrace: [{couch_util,get_nested_json_value,2},
             {couch_httpd_show,handle_doc_update_req,2},
             {couch_httpd_db,do_db_req,2},
             {couch_httpd,handle_request,5},
             {mochiweb_http,headers,5},
             {proc_lib,init_p_do_apply,3}]
1> [debug] [<0.11411.0>] httpd 404 error response:
 {"error":"not_found","reason":"json_mismatch"}


On 27 April 2010 14:48, Adam Kocoloski <kocolosk@apache.org> wrote:
> No, validation functions cannot modify documents.  The usual reason given is that they
run during replication as well as during client updates.
>
> Adam
>
> On Apr 27, 2010, at 8:40 AM, Andreas Köberle 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 <kocolosk@apache.org> wrote:
>>> That's correct, Simon, _update handlers don't work with _bulk_docs today.  Best,
>>>
>>> Adam
>>>
>>> On Apr 27, 2010, at 8:07 AM, Simon Metson wrote:
>>>
>>>> Hi,
>>>>       Is it possible to apply an update function to a bulk insert? 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öberle 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.
>>>>>
>>>>
>>>
>>>
>
>

Mime
View raw message