I have a few questions around the best strategy for deleting/purging. The goal is keep the mobile device lean and reduce the amount of data that is sent when a new device is logged into.
Currently without any purging all the activity over the lifetime of the user account is synced to the relevant channels and the database can grow without bounds. Users can share data with other users as well, so the data that is on their device wasn't necessarily created by that user as well.
1) I can purge a document from the device easily, but what is a strategy to purge documents that were sent to the device via a sync? Add a change listener to the database and if the document has a deleted revision and meets some purge criteria purge it from that device as well?
2) The second, and critical issue, is that all the documents over the lifetime of the channel are sent to the device via a sync. If a user creates and deletes thousands of documents over time, then logs into a different device all of those revisions are sent to the database, even if they were deleted. There may be minimal relevant data but tons of data may still be sent to the database.
I can't think of a good strategy for this. Ideally I think the Sync Gateway should only send documents that don't have a deleted revision, if the document was created and deleted in the timeframe since the last sync of that device+channel. I can't think of a way to get around this. We have use cases where users may log in from their other devices and can't limit the amount of data that is sent to that device.
A simple example would be with the ToDo app. If I create and delete thousands of items over a few months, then log into my account with my other devices I receive all the old deleted items from before.
Hopefully there is an easy way around this, let me know if you have any ideas or need some clarification.
-james