문제

This is how I get the document and check for newer revisions:

curl  http://localhost/cdb/characters/e6b153975174556adc0b344e9a000a7f?revs=true

returns:
{"_id":"e6b153975174556adc0b344e9a000a7f","_rev":"1-25b25539eca3944ef8d8f20748ed4902","name":"Barack Obama","position":"US President"}

Then I try to delete that doc like this:

curl -X DELETE http://localhost/cdb/characters/e6b153975174556adc0b344e9a000a7f?rev=1-25b25539eca3944ef8d8f20748ed4902

response:
{"error":"conflict","reason":"Document update conflict."}

Why, if there doesn't seem to be an issue with revision, is there a document conflict on delete?

Is there a problem with deleting a doc that has no other revisions?

도움이 되었습니까?

해결책 2

First, since your code looks correct as is, check that your params are in fact being sent.

Otherwise, you should check if a revision is marked as deleted:

curl -X GET http://127.0.0.1:5984/kina/  \
 04ce1239166b841ae8a317897ec45b11?revs_info=true
{
  "_id":"04ce1239166b841ae8a317897ec45b11",
  "_rev":"3-bc27b6930ca514527d8954c7c43e6a09",
  "_revs_info":
  [
   {
    "rev":"3-bc27b6930ca514527d8954c7c43e6a09",
    "status":"available"
   },
   {
    "rev":"2-eec205a9d413992850a6e32678485900",
    "status":"deleted"
   },
   {
    "rev":"1-967a00dff5e02add41819138abb3284d",
    "status":"available"
   }
  ]
}

To get rid of the deleted versions, you have to use _purge. For example:

curl -X POST http://127.0.0.1:5984/kina/_purge/ \
     -H "content-type:application/json" \
     -d ’{"7341477ce373f9cc76f351e598001cdd":
           ["2-5c7fb5dfeaf6f7cea149922fa1cdaf96"]
        }’

{
  "purge_seq":1,"purged":
  {
    "7341477ce373f9cc76f351e598001cdd":
    ["2-5c7fb5dfeaf6f7cea149922fa1cdaf96"]
  }
}

다른 팁

Deleting a doc which has other revisions is done:
curl -X DELETE http://couchhost:5984/couchdb/docid\?rev\=rev_number

This helped me when getting
{"error":"conflict","reason":"Document update conflict."}

This is not a direct answer, but, to some people like me that were coding too late and thought the query parameter was named _rev instead of rev, just remove that underscore.

(I actually had to go as far as to enable couchdb debug logging to compare the http request received by couchdb when sent from fauxton vs. my app)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top