0

I am trying to Delete the whole data from the CouchDB and again i am trying to write same data with modified **_id field and some extra field **

but i am getting following error :

{ 'reason' => 'Document update conflict.', 'error' => 'conflict', 'id' => 'test_1' }, { 'reason' => 'Document update conflict.', 'error' => 'conflict', 'id' => 'test_2' },

How to resolve the error ?

saravanakumar
  • 919
  • 1
  • 8
  • 8
  • 1
    Can you provide a full list of curl commands (or API calls, though those are less useful since it's unclear what they do under the hood) that reproduce the error? – Eli Stevens Aug 28 '14 at 21:59
  • Looks like you didn't pass your _rev when updating... but this is just in theory, as you didn't provide us any details. – sebster Aug 29 '14 at 14:35
  • Hi All, In my Couch DB _id is the primary key. If I change the primary key of the DB means, It will automatically create a new _rev(version). Then why do I need to pass the old _rev ?. Suppose if I pass old _rev, what will happen or what error will I get ? – saravanakumar Aug 30 '14 at 08:59
  • Hi WickedGrey, I am not using curl command. Instead of that I am using HTTP module through the Perl scripting. – saravanakumar Aug 30 '14 at 09:05

1 Answers1

0

When creating new document "test_1", there should be a document with that name already having a different _rev in your db. If you need to update the old "test_1", you need to provide the _rev of that document when updating. Or else, you can delete "test_1" and then try creating another document with the name "test_1". The point here is, you should provide the latest _rev of a certain document, when updating that document.

Sanj
  • 65
  • 7
  • Thankyou @Sanj. Now I got it.I have a question. For deleting the particular or Whole document, I am setting the HTTP Content like this _deleted:true in my code. That means will it delete from the DB memory or it just hide the data from the GUI and it will keep the data in behind the screen ? Because why i am asking this question means, If I am deleting the particular or whole document from the DB and again writing the same document to that DB, that time the _rev id just got updated from the last version id instead of start from 1. – saravanakumar Sep 01 '14 at 17:58