使用c#,couchdb和LoveSeat的正确的hello world程序是什么

|| 我正在尝试在C#中将一个简单的hello世界存储在一个ouchdb数据库中(总共是新手)。 我正在使用LoveSeat(但如果有帮助,可以随时建议其他客户)并创建了以下简单代码:
static void Main(string[] args)
{
    var cl = new CouchClient(\"myserver\", 5984, null, null);

    var db = cl.GetDatabase(\"mydb\");

    var newDoc = db.CreateDocument(@\"{
\"\"Test\"\":\"\"ValueTest\"\"
}\"
    );

    var newDoc2 = db.SaveDocument(newDoc);
}
该文档实际上是创建的:
{
   \"_id\": \"805656b6113d30a5387230a669000bb6\",
   \"_rev\": \"1-44c5768a2fa004c6a43899687c283517\",
   \"Test\": \"ValueTest\"
}
但是当我查看生成的newDoc2时,我看到了:
{
  \"error\": \"file_exists\",
  \"reason\": \"The database could not be created, the file already exists.\"
}
我做错什么了吗 ? 谢谢
已邀请:
CreateDocument实际上是将新文档添加到beddb的功能。此后无需调用SaveDocument。更改文档后,将使用SaveDocument来更新文档。我不确定,但是似乎在尚未更新的文档上调用SaveDocument会出现此错误。如果您对文档进行更改,然后调用SaveDocument,我希望它会正常工作。
我阅读了LoveSeat的源代码:
public Document SaveDocument(Document document)
{
    if (document.Rev == null)
        return CreateDocument(document);

    var resp = GetRequest(databaseBaseUri + \"/\" + document.Id + \"?rev=\" + document.Rev).Put().Form().Data(document).GetResponse();
    var jobj = resp.GetJObject();
    //TODO: Change this so it simply alters the revision on the document past in so that there isn\'t an additional request.
    return GetDocument(document.Id);
}
因此如果为
document.Rev==null
,则SaveDocument与CreatDocument相同 如果为“ 5”,则SaveDocument实际上是\“ UpdateDocument \”。 您的代码属于前一种情况:
document.Rev==null

要回复问题请先登录注册