0

I am using the Cloudant node module to modify my Cloudant database. I am sending the following documents to the db.bulk(params,callback) function.

{ docs: [
   { "_id": "...",
     "_rev": "...",
    "_deleted": true
   },
   { "_id": "...",
     "_rev": "...",
    "_deleted": true
   },
   { "_id": "...",
     "_rev": "...",
    "_deleted": true
   },
   { ... }   
]}

After I call this function I do not get any errors but when I try and query the database later I am still getting the deleted documents back? I know that Cloudant has "tombstone documents" so they should still be there but I don't really see tombstones at all I just see the documents I wanted to delete sitting in my database with a new _rev number and returned as if they are still active.

Even when I try to query the database with a selector deleted: true I get nothing back.

Am I missing something?

P.S If you are wondering why I put "_deleted" in the bulk document I was just following what this site said to do.

Danwakeem
  • 328
  • 2
  • 17
  • 1
    In a bulk operation, some changes may fail while others succeed. Did you check the actual response rather than just the `err` parameter? – OrangeDog Jun 22 '16 at 13:57
  • Yes I did and it passes back the _id and _rev number for each document which is the expected behavior for deleting documents according to the documentation [on this page](http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API). – Danwakeem Jun 22 '16 at 14:01
  • And when you query them later, do they have the _rev that was returned, the original _rev, or something else? – OrangeDog Jun 22 '16 at 14:02
  • Okay hang on I must have changed something a minute ago because I just checked the response for the documents and now it is telling me I have a document update conflict. – Danwakeem Jun 22 '16 at 14:06
  • Ahh found it! The method I just added modified some of the documents so the _rev number was out of date. Thank you @OrangeDog I appreciate the help! – Danwakeem Jun 22 '16 at 14:08

1 Answers1

1

In a bulk operation, some changes may fail while others succeed.

You need to check the actual response for each update rather than just the err parameter. Even if err is null, it may be the case that every update failed for an individual reason, for example a revision conflict.

OrangeDog
  • 36,653
  • 12
  • 122
  • 207