couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <>
Subject Re: validate_doc_update modifying doc?
Date Thu, 30 Apr 2009 10:42:32 GMT
On Wed, Apr 29, 2009 at 04:47:41PM +0200, Wout Mertens wrote:
> On Apr 29, 2009, at 11:14 AM, Chris Anderson wrote:
>> However, I think we should add an _update handler which allows  
>> JavaScript
>> to transform arbitrary input into JSON before saving. This should open 
>> up
>> the range of possibility a bit without JS needing the ability to make
>> HTTP calls.
> Hmmm... Could that then be used to update only one field of a doc? How  
> would this work with revisions?

It could, if the input to the function included the original doc. Perhaps
something like:

  function(post_body, oldDoc, userCtx, http_headers) {

In that case, it could emit a new document which is oldDoc merged with

It could be useful if post_body were first decoded into an object following
the way that Rack/Rails handle form posts:

  foo=1&bar=2                 =>   {"foo":"1","bar":"2"}
  foo[]=1&foo[]=2             =>   {"foo":["1","2"]}
  foo[bar]=1&foo[baz]=2       =>   {"foo":{"bar":"1","baz":"2"}}



View raw message