0

I need to recreate a document in CouchDB. I use nano package, but I think the problem is the same with API calls. What I'm currently doing is to make two calls:

await dbHandle.bulk({docs: [{_id: "abc", _rev: "12-aaaa", _deleted: true}]});
await dbHandle.bulk({docs: [{_id: "abc", content: "...."}]});

But if I combine the two calls into one, the creation gives conflict:

await dbHandle.bulk({docs: [{_id: "abc", _rev: "12-aaaa", _deleted: true},
                            {_id: "abc", content: "...."}]});

But shouldn't the document be created with a different _rev value, so no conflict?

I agree that the difference between the two methods is minor, but I want to understand how deletions are synchronized. I have few problems during testing that seems caused by delete operations continuing in background somehow. Sure I'm doing something wrong, but I need to be sure.

Thanks for enlighten me!
mario

SiliconValley
  • 1,465
  • 17
  • 30
  • 1
    When a document is marked _deleted the allDocs index is affected. I believe you are getting a conflict because the index has not been updated for the deletion at the time the new document with the same _id is processed. – RamblinRose Apr 16 '23 at 22:19

0 Answers0