couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johs Ensby <j...@b2w.com>
Subject Re: [PROPOSAL] Allow rewrites to be JS function
Date Thu, 08 Oct 2015 19:17:14 GMT
Thanks for going all the way and provide a AMI for testing, ermouth!
It's going to be an interesting weekend

3  questions:
1) could you post an examples here for simpel rewrite function with all parameters in use?
2) can you confirm that you now can turn a GET into a PUT and if you need to, redirect to
an _update function?
3) do you see this replacing the _update function?

johs

PS
Thanks for supporting, Alexander

> On 8. okt. 2015, at 20.59, ermouth <ermouth@gmail.com> wrote:
> 
> Dear couchappers!
> 
> My collegues created Amazon EC2 AMI image with Ubuntu 14.04 and CouchDB
> 2.0.4ca9e41 + JS-rewrite patches applied over it. AMI image is publically
> available under AMI ID ami-29ecda5e (section ‘Community AMIs’).
> 
> You can launch your own instance from this AMI and have empty CouchDB2
> (with JS rewrites) auto-launched in single-node mode. When creating your
> EC2 instance do not forget to allow access to your instance from your IP
> (create Security Group with appropriate network settings).
> 
> Short specs
> ------------
> 
> Any design doc for this fork can have .rewrite section, defined as a
> string, containing function. ‘Classic’ array format is surely also
> supported.
> 
> Rewrite function receives one argument, req2 object, that is lean version
> of req object for list functions. Unlike lists, rewrite function‘s req2 obj
> does not have properties .id, .uuid, .info, .requested_path and .form. All
> other properties are in place.
> 
> Rewrite function must return object of structure {path:String,
> method:String, code:Number, headers:Object, body:String}. The property
> .path is mandatory, all other properties are optional.
> 
> Some hints on usage
> ------------
> 
> Using js rewrites you can, for example:
> * create per-user DBs from non-admin requests;
> * allow users to self-register;
> * have fair multi-user shared DBs with restricted replication;
> ...etc.
> 
> Will be happy to hear other scenarios from you! Play with it and explore
> boundaries of the feature.
> 
> Please, feel free to ask questions.
> 
> BR,
> ermouth
> 
> PS. Code was reviewed by @kxepal (Alexander, thank you for it!), and
> received several not yet fixed non-critical remarks. I‘m working on
> cleaning em up. Please note: this preview is NOT intended for production
> and does not support Erlang rewrite fns, only JS.


Mime
View raw message