We have 1lakh + records in the server, all documents are getting synced when first time app launched. After that we querying for the documents which are older than 5 days, we are purging them. Is there an option to know the document details on sync (on notification triggered as it is in iOS) so that we can purge it then and there is it is older instead of running the loop.
Note: We are planning to setup channels but to overcome the situation now is there any quick alternate way.
I don’t quite understand the scenario. Are you looking to purge the older documents from local database (Couchbase lite) or are you looking at doing it on the Sync Gateway. Regardless note that you would want to do a delete and not a purge. Deletes get replicated not purges.
hi @priya.rajagopal I was trying to purge on local database to free up space on the device not delete.
Hi , As indicated above, Purges won’t get replicated so which means that even if you purge the doc from your local store, it can still be replicated again. You would want to do a delete first to propagate the change followed by a purge. This related post discusses this.
As a FYI: Couchbase lite system will periodically prune away old and unused revisions based on maxRevTreeDepth
and it also uses document’s expirationDate
to get rid of old revisions . You can read more about it in this blog .
Aside from this , in a real prod environment, you would have to handle this through a process on the server side that periodically moves old documents from the user’s active channel (one that syncs) into a “history” channel that doesn’t get synched