After reading this paragraph in the CouchDB Ultimate Guide ( here ):
If you have several project documents, each of which has a validate_doc_update function, all these functions are called with every incoming write request. Only if all of them pass will the recording be successful. The order of verification is not defined. Each verification function must act on its own.
I am wondering if there is good practice to work with multiple validate_doc_update functions?
I mean: is it better to create only one project document with the validate_doc_update field or have a few smaller ones?
In the first case, you can be sure that none of the verification functions will interfere with the other, but the function can become very large if many controls are required.
On the other hand, a few smaller functions may be easier for reading and evolutionary purposes, but everyone should be sure of the purpose of each function and not mess with the others.
Plus, what does it mean that every design document contains a validation function? For example, storing one document in a view seems a little dirty, but creating several project documents just for the intention of having one small validation function does not seem very smart to me.
What do you think?
Maybe I missed something, that is the point of my question, are there any good practices in managing multiple validate_doc_update functions?
source share