Skip to content

can't recover deleted document #3177

Answered by wohali
maxlath asked this question in Q&A
Discussion options

You must be logged in to vote

You do not need to specify the deleted rev if you are re-creating a previously deleted document. This example works:

curl -XPUT "http://localhost:5984/some-db"
rev1=$(curl -XPUT "http://localhost:5984/some-db/foo" -d '{"bar":123}' | jq '.rev' -r)
rev2=$(curl -XDELETE "http://localhost:5984/some-db/foo?rev=${rev1}" | jq '.rev' -r)
curl -XPUT "http://localhost:5984/some-db/foo" -d '{"bar":123}' | jq '.rev' -r

This adheres to the principle of least surprise -- you shouldn't have to have prior knowledge about the tombstone (deleted document)'s _rev value just to re-create the document.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by maxlath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3177 on October 05, 2020 16:29.