Purging deleted documents from local db through API

Hi,

we need to cleanup our database periodically as it grows and devices are becoming very slow. In order to achieve that we:

  1. Delete old documents on the server through Sync Gateway REST API
  2. Synchronise deleted revisions to the devices through pull replication
  3. Run compact on the local database

Apparently running compact on the local database does not purge deleted documents.

Is there a way to purge all deleted documents after pull replication through the Couchbase Lite API? We do not have the REST API setup on the devices.

The only way I can think about is to create a view and purge documents one by one.

Regards,

Yuzkan

Deletion is not the same as purging.

To purge documents on the client, use the Document.purgeDocument method.

Thanks, jens.

Is that the only way to purge documents by purging one by one? Like I explained above by having a view to get all deleted documents and then go through the list.

I was looking for some kind of automated way to purge all deleted documents at once.

There’s no built-in mechanism to purge deleted documents. But it just takes a couple of lines to do it yourself. If you don’t want to create a view, you can just run an all-docs query, with the mode that includes deleted documents.