Couchdb 沙发和沙发帮助

Couchdb 沙发和沙发帮助,couchdb,couchapp,couchdb-futon,Couchdb,Couchapp,Couchdb Futon,几周前,我刚接触过Couchdb,我克隆了名为sofa的Couchdb应用程序。一周来,一切都很顺利,但今天我突然发现了一些事情 这就是我的意思 当我浏览沙发应用程序并尝试创建一篇没有标题的帖子时 它会提示并警告框“文档无法保存:数据库无法创建,文件已经存在。”这很奇怪,因为查看源代码时,我发现require(在validate_doc_update.js中返回其自定义json错误)类似于以下格式{“禁止”:message})以禁为键 v.forbidden = function(messa

几周前,我刚接触过Couchdb,我克隆了名为sofa的Couchdb应用程序。一周来,一切都很顺利,但今天我突然发现了一些事情

这就是我的意思 当我浏览沙发应用程序并尝试创建一篇没有标题的帖子时 它会提示并警告框“文档无法保存:数据库无法创建,文件已经存在。”这很奇怪,因为查看源代码时,我发现require(在validate_doc_update.js中返回其自定义json错误)类似于以下格式{“禁止”:message})以禁为键

  v.forbidden = function(message) {
      throw({forbidden : message})
  };

   v.require = function() {
        for (var i=0; i < arguments.length; i++) {
          var field = arguments[i];
          message = "The '"+field+"' field is required.";
          if (typeof newDoc[field] == "undefined") v.forbidden(message);
        };
      }; 
检查返回的json与验证文档更新.js中的上述require函数返回的json不同的响应状态 这里是json {“错误”:“文件_存在”,“原因”:“无法创建数据库,文件已存在。”}

这使人相信,在文档更新期间,validation_doc_update.js中的验证仅执行

为了证明这一点,我尝试更新一个没有标题的文档,期望它会返回错误,但令人惊讶的是文档刚刚被保存

这是关于我上面提到的所有问题

validate_doc_update.js“validate”是否仅在文档更新期间有效

if YES 
   then 
      how can I manage to succeed in updating a post without the error [Weird bypassing the Validation Completely] . +  How can execute validation on create of a document
if NO
   then 
     What is  the Error {"error":"file_exists","reason":"The database could not be created, the file already exists."} that is prevent a document to be saved  

任何人都可以分享这里列出的所有问题吗?

是的,只有在更新文档(包括创建和删除)时才会运行验证文档更新功能

您在此处显示的函数将允许没有标题的文档,只要其类型不是“post”。如果你能把你尝试的实际请求包括在内,我可以确认


最后,“无法创建数据库”是因为您试图在数据库已经存在时创建数据库(我猜是通过执行PUT/dbname/而不是PUT/dbname/docid)。同样,如果您将实际请求包括在内,我也可以确认。

point accepted@Robert,但还有一些事情尚不清楚[1]上面的错误{“error”:“file_exists”,“reason”:“无法创建数据库,文件已经存在”}是在我在“sofa”中创建新的“post”记录时生成的“创建新数据库时,如果有人试图创建一个已经存在的数据库,但在创建记录时产生的错误很奇怪,我知道会出现上述错误,因此,请您分享更多信息[2]如果validate_doc_update.js在创建期间也验证了记录,那么为什么在sofa应用程序中应用验证来确保没有创建没有标题的帖子不会产生相同的错误?如果在创建帖子时没有提供标题,那么在创建帖子期间跳过验证。
if YES 
   then 
      how can I manage to succeed in updating a post without the error [Weird bypassing the Validation Completely] . +  How can execute validation on create of a document
if NO
   then 
     What is  the Error {"error":"file_exists","reason":"The database could not be created, the file already exists."} that is prevent a document to be saved