couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antony Blakey <>
Subject Re: Document Updates
Date Fri, 14 Nov 2008 00:49:07 GMT

On 14/11/2008, at 11:01 AM, Antony Blakey wrote:

> On 14/11/2008, at 10:39 AM, Chris Anderson wrote:
>> On Thu, Nov 13, 2008 at 3:37 PM, Noah Slater <>  
>> wrote:
>>> I did some digging to see what else is out there:
>>> *
>>> *
>>> *
>>> *
>>> *
>> Forgive me for throwing out a loose-cannon idea, but would it be
>> easiest to provide an API where the user sends a Javascript function
>> to CouchDB via the PATCH method? The function could look something
>> like:
>> function(doc) {
>> doc.my_field = "new value";
>> doc.existing_array[3] = "another new value";
>> doc.new_array = ["a", "b", 3];
>> return doc;
>> }
> I thought that javascript wasn't part of the Couch core? JSON isn't  
> javascript, and all uses of javascript *could* be replaced with e.g.  
> Ruby (or my interest, Smalltalk), which is why there is a "language"  
> attribute on the views.
> Your proposal would change that.

You could use the view mechanism, and attach a "language" attribute,  
and have this be a general transformation interface, which would  
indeed be very nice. For efficiency you would want to apply this over  
sets of documents, and probably in a transactional context like bulk  
update does now.

However... Damien wants something to use in replication, which would  
mean that javascript would then become a required, rather than an  
optional part of Couch, because replication would require it (unless  
you made the replication diff generator pluggable ... but why go  
there?). The benefit of the declarative diff format is that applying a  
diff can be done within Couch.

Antony Blakey
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787

It's amazing that the one side of the conversation that survived is "I  
don't know art, but I know what I like". The reply from the artist was  
"Madam, so does a cow".
   -- Carl Kirkendall

View raw message