Hi.
Could someone give me a pointer as to why this works:

{
  "_id": "_design/must_have_field_verifier",
  "_rev": "14-7aa573a99ec8cb007edfe6c8dd72ba15",
  "validate_doc_update": "function(newDoc, oldDoc, userCtx) {
 function require(field, message) {
 message = message || \"Document must have a \" + field;
  if (!newDoc[field]) throw({forbidden : message});
};
{
 require(\"abc\");
 }
}"
}


but 'abc.def' is not recognised in the code below, although the code is
read and applied:



{
  "_id": "_design/must_have_field_verifier",
  "_rev": "14-7aa573a99ec8cb007edfe6c8dd72ba15",
  "validate_doc_update": "function(newDoc, oldDoc, userCtx) {
 function require(field, message) {
 message = message || \"Document must have a \" + field;
  if (!newDoc[field]) throw({forbidden : message});
};
{
 require(\"abc.def\");
 }
}"
}



The reply is "Save failed: Document must have a abc.def"




I have tried including : &&(||) typeof  (!newDoc[field]) === 'object'
inside the if statement but the code is not accepted as valid.

Sorry. Wish there was a beginners section here.

If I wanted an easy route I would use Mongo. But Couch is a much more
eloquent system!!



John

Reply via email to