Permission Changes / Local Database Orphaned Docs?

I am building an app where permissions to various channels is dynamic based on rules in my sync function that assign users/roles to channels, etc (ok, I guess this part is obvious).

I login to the app and do a sync which pulls down a bunch of documents that currently I have permission to. Later, an admin changes my permissions such that I no longer have access to some of those docs (no longer have access to the channel they were published on).

My understanding is that after this my local database will still have docs that I no longer should have permission too. Sync won’t pull down never versions of those docs, but the local docs will still exist.

Is there a strategy for how to handle this? How do I remove docs that are already in the local database if they should no longer be synced?

There is an issue open on GitHub for what you are describing and tagged with the 1.2.0 release. You can upvote the feature request.


Thanks for the link :slight_smile: Between this and the fact that PouchDB doesn’t support being able to purge documents either (so I can’t even do it myself manually), it pretty much just demolished the data architecture for my app. It means if the dynamic security model changes, there is no way to get rid of local data in the application that the user no longer has permissions too without deleting the entire database and resynching everything from scratch. That just isn’t gonna work. Back to square one :frowning: