jcoglan opened a new pull request, #5839:
URL: https://github.com/apache/couchdb/pull/5839

   ## Overview
   
   This PR implements "phase 1" of the functionality outlined in #5792, i.e. it 
adds the ability for `validate_doc_update` to be implemented as a Mango 
selector expression, rather than as a JavaScript function. The selector is 
evaluated against an ephemeral JSON structure containing `newDoc` (the new doc 
version to be saved) and `oldDoc` (the one currently on disk). For example, 
saving the following to `/db/_design/mango-vdu` will cause all docs to be 
checked for a `type` field which must be a string:
   
   ```json
   {
     "language": "query",
   
     "validate_doc_update": {
       "newDoc": {
         "type": { "$type": "string" }
       }
     }
   }
   ```
   
   This uses the existing infrastructure of `couch_query_servers` and 
`mango_native_proc`, just adding appropriate message handlers to Mango 
processes for handling VDU requests.
   
   ## Testing recommendations
   
   The added tests cover the basic functionality to check that Mango validators 
can be saved, and the in-memory cache is updated as appropriate. It assumes 
Mango works as it does in current releases and so does not re-test all the 
Mango functionality in detail.
   
   Since there are now two different languages VDUs can be written in, I may 
have missed anything that assumes there's only one way to do it. I did however 
notice a counter being updated incorrectly, which is now fixed.
   
   ## Related Issues or Pull Requests
   
   - https://github.com/apache/couchdb/pull/5792
   
   ## Checklist
   
   - [ ] Code is written and works correctly
   - [ ] Changes are covered by tests
   - [ ] Any new configurable parameters are documented in 
`rel/overlay/etc/default.ini`
   - [ ] Documentation changes were made in the `src/docs` folder
   - [ ] Documentation changes were backported (separated PR) to affected 
branches
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to