How to revert changes to couchdb?

I did bulk editing into a bunch of documents in my couleb, but I made a mistake and wrote the field incorrectly. I see that the previous revision is there. How to get back to it?

+4
source share
1 answer

My last best guess, based on this:

http://guide.couchdb.org/draft/conflicts.html

... is to find the document id and revision ID, and then send a deletion for that document indicating the version I want to delete.

curl -X DELETE $HOST/databasename/doc-id?rev=2-de0ea16f8621cbac506d23a0fbbde08a 

I think this will leave the previous revision. Any better ideas out there?

I had to write some coffeescript (using underscore.js and jquery.couch ) to do this. This is not a real comeback, because we get the old revision and create a new revision. Still looking for the best deals:

  _.each docsToRevert, (docToRevert) -> $.couch.db("databaseName").openDoc docToRevert.id, revs_info: true , success: (doc) -> $.couch.db("databaseName").openDoc docToRevert.id, rev: doc._revs_info[1].rev #1 gives us the previous revision , success: (previousDoc) -> newDoc = previousDoc newDoc._rev = doc._rev result.save newDoc 
+3
source

All Articles