1

I would like to recover deleted document. I did following

To get id of doc:

curl http://127.0.0.1:5984/shareddb/_changes

{"seq":"138-g1AAAACbeJzLYWBgYMpgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUklMiTV____PyuDOdE9FyjAnmxmbmiemohNAx5j8liAJEMDkPoPNc0ZbJpJiqG5iUEyNn1ZAJoKMSU","id":"25df5fb6-9a9d-43fa-9bb2-2b7dc6f67e51","changes":[{"rev":"5-a116b399e972ef9353c418e907b0eaaa"}],"deleted":true}

After getting the id

curl http://127.0.0.1:5984/shareddb/25df5fb6-9a9d-43fa-9bb2-2b7dc6f67e51?revs=true&open_revs=all

{"error":"not_found","reason":"deleted"}

Also, I tried following

curl http://127.0.0.1:5984/shareddb/25df5fb6-9a9d-43fa-9bb2-2b7dc6f67e51?revs_info=true

{"error":"not_found","reason":"deleted"}

Basically I want to put the doc again as suggested in http://garmoncheg.blogspot.com/2013/11/couchdb-restoring-deletedupdated.html

Please suggest if there is any other solution to recover deleted documents. As far as I know, there is no rollback in CouchDB. Please correct me if I'm wrong.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Apogee
  • 689
  • 8
  • 19
  • I think you can definitely restore your deleted document, since the document is available, it's `deleted` key is just set to`true` – Megidd Aug 13 '18 at 14:15
  • @user3405291 Yes I agree. CouchDB doesn't delete the doc. But I don't know how to recover the deleted doc – Apogee Aug 14 '18 at 01:54
  • Can you try using this? https://www.npmjs.com/package/couch-undelete but I assume that database has been compacted and there's no previous revision available. Using Fauxton, you can easily browse previous versions – Alexis Côté Aug 14 '18 at 16:44
  • @AlexisCôté Thanks for the suggestion but couch-undelete itself says **This is has been done quickly and should not be used in a production environment.** So I don't think its a good option. – Apogee Aug 15 '18 at 02:49
  • I'm the author of this package. You can always look at the code available here: https://github.com/popojargo/couch-undelete/blob/master/index.js but it seems like I did the same thing as you. If you use [Photon](https://github.com/ermouth/couch-photon), you can browse your document revision. – Alexis Côté Aug 15 '18 at 13:32

0 Answers0