Purging Null Documents

Hi All,

Need a little help here . I am trying to delete the null documents while uploading the data to the server.
My code looks something like this . However , I get an error saying “java.lang.IllegalArgumentException: document cannot be null”

I am not sure how these null documents are created but I want to delete them before uploading data to the server .Any suggestions please?

Document d = database.getDocument(result.getString(“id”));
catch (NullPointerException e) {



don’t quite understand your question. the document d seems not exist, because when the getDocument call returned a null object. then why do you want to delete if the document does not exist?

I guessed that the document is deleted. If the document was deleted (not purge), when getting the document with ID, the null object will be returned. To purge a deleted document, you will need to purge with the document ID instead of document object.

Thanks, @pasin. I checked version 2.7, which has overloaded purge function, but 2.0 only has purge function which only takes Document as a parameter. Do you recall since which couchbase lite version, the purge function started to take document ID?