How to purge documents which are replicated to server?

56 views
Skip to first unread message

Karthik Rajagopalan

unread,
Apr 5, 2016, 11:33:04 PM4/5/16
to Couchbase Mobile
Hi Folks,

I just started using couchbase lite and playing with it. I have set of documents which fall under 'logger' category and the rest under different categories. These documents are written on a periodic basis. I have configured push replication to be continuous. I like to know the best practice to "purge" documents which fall under 'logger' category on a periodic basis in local db once these documents are replicated to the server.  Should I just iterate through all documents and purge which are 'logger' category and is not contained in getPendingDocumentIds()? Should this be done once the push replication become 'idle'? 

-Karthik

Jens Alfke

unread,
Apr 7, 2016, 2:28:40 PM4/7/16
to mobile-c...@googlegroups.com

> On Apr 5, 2016, at 8:19 PM, Karthik Rajagopalan <kar...@gmail.com> wrote:
>
> Hi Folks,
>
> I like to know the best practice to "purge" documents which fall under 'logger' category on a periodic basis in local db once these documents are replicated to the server.

We don’t have good support for this use case yet, although we plan to improve that in version 1.3.

> Should I just iterate through all documents and purge which are 'logger' category and is not contained in getPendingDocumentIds()? Should this be done once the push replication become 'idle’?

For now that would be the best approach. (You can use a view query to iterate the ‘logger’ documents.)

—Jens

Todd Freese

unread,
Apr 7, 2016, 4:11:03 PM4/7/16
to Couchbase Mobile
+1 on this improvement. That would be very helpful to me too.

T

Jens Alfke

unread,
Apr 7, 2016, 4:34:56 PM4/7/16
to mobile-c...@googlegroups.com

On Apr 7, 2016, at 1:11 PM, Todd Freese <to...@filmworkers.com> wrote:

+1 on this improvement. That would be very helpful to me too.

This is available on the master branch of the iOS repo; here’s the commit.

In a nutshell: if you set “purgePushed” to true in the customProperties of a CBLReplication, the replicator will purge docs from the database shortly after they’re successfully uploaded to the server. (Obviously you probably want to set up a filter too, otherwise all the docs in the database will end up being purged…)

—Jens
Reply all
Reply to author
Forward
0 new messages