Q:

Using Couchbase Lite and Sync Gateway, how to have documents from revoked channels removed?

I'm developing an application with Couchbase Lite on client side, and Couchbase Sync Gateway on server side.
On server-side, I manage "access grant" documents. When such a document is created, the user given in that document is granted access to a channel. Obviously, when such a document is removed, access grant is revoked. It is indeed the case, excepted for one point.
Suppose I have one document that is published in the channel my user is granted access to. Then I delete the document. According to Couchbase documentation, once the document is removed, the user has no more access to the channel denoted in access grant.
Unfortunatly, the documents that were published into that channel have already been synchronized with user couchbase lite DB. Hence my question : I would like to have documents associated with channels for which the user have no more access be deleted from couchbase lite. But how can I do that ? It doesn't seems that either replication or lvie queries can allow this. So, is there a specific mechanism that can allow me to receive that kind of event ? Is there an API I do not yet know ?

A:

Documents are assigned to channels.  Users are given access to channels.
If a document is removed from a channel, this event is synced to a client.  
Currently there is no support for notifying a client that it has lost access to a document because it has lost rights to read from a channel.
This is a difficult problem.  For example, since a document may be assigned to many channels, revoking access to a channel (or even a set of channels) does not mean a client no longer has access to the document.
To see two possible approaches to work around this, see this GitHub issue comment series.

