couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Heike Bernhard <heikebernh...@gmx.de>
Subject Validate_doc_update required fields - can't delete documents
Date Fri, 08 Jan 2010 23:11:31 GMT
Hello,

I'm new to CouchDB and I've just wrote my first validate function
(thanks to the book "CouchDB: The definitive guide"). But now I have a
problem, when I want to delete documents.

For each document there are two fields required (firstName and lastName)
and my function looks like this:

"validate_doc_update": "function(newDoc, oldDoc, userCtx)
{
  function require(field, message)
  {
    message = message || \"Document requires the field \" + field;
    if (!newDoc[field]) throw({forbidden : message});
  };
  if (newDoc)
  {
    require(\"lastName\");require(\"firstName\");
  }
}"

So if I want to delete a document, I get an error, because of the
required fields:

user@computer:~$ curl -X DELETE
http://username:password@localhost:5984/testdb/foo?rev=6-5f2e9784c354bdf95e2d851f7f87d045
{"error":"forbidden","reason":"Document requires the field lastName"}

What am I missing?
Thanks for any hints.

Heike



Mime
View raw message