How are removing channels from a document handled in the change feed

CB5 Beta / SG 1.5 Beta

When i delete a document in CB i can see this in the SG change feed as deleted, which is handled as a delete by my client (current pouchdb for protoyping).

{
“seq”: 672243,
“id”: “customerdocument_5c43a935-c18a-11e6-853c-00185161942f_28d4546b-e28d-11e6-a8da-001851c6bce1”,
“deleted”: true,
“removed”: [
“caregroup_12345”
],
“changes”: [{
“rev”: “2-860efa627e6a794ea5914be7b251ad98”
}]
}

However when I remove a channel ‘caregroup_12345’ from a document which is the only channel this user has, then it comes through as an update.

{
“seq”: 672204,
“id”: “tasks_4e0bbcf3-380f-42fc-9b34-29725b0232bb_9877770”,
“changes”: [{
“rev”: “2-ee42505bd7dfd8dc09dd8e99f68462e4”
}]
}

This makes sense because the document has been updated and i can see in rev2 that the channel has been removed. But the client doesn’t seem to have a way to know that this documents is now outside of the sync view because of the channel removal.
How is the client to know that this document should be removed for the local view?
As i’d expect from the feed pouchdb just handles this as an update. I’d raise this as a bug with pouch but I dont understand how it could work.

@adam.hawkins

Can you confirm that you are connecting to Sync Gateway as an authenticated user on the Public REST API.

Believe so ,

Accessing this url which requires basic auth credentials.

http://cbhost:4984/pass/_changes?style=all_docs&since=671538&limit=1000

The user i’m logging in with a user that has a number of channels create via the admin api

PUT http://cbhost:4985/_user/testuser

This user has channel ‘caregroup_12345’ so sync’s down all the documents correctly.
But when the document is has this channel removed there’s no indication that it falls outside the user sync view aside from the update to the document on the client which no longer has that channel.

Unless the client knows which channels the user has access to I can’t see how the consumer of the changelog can determine that the updated document falls outside of the users channel list.

Have you tried querying for changes feed using the active_only as true.
Description "Default is false. When true, the changes response doesn’t include either deleted documents, or notification for documents that the user no longer has access to."
https://developer.couchbase.com/documentation/mobile/1.4/references/sync-gateway/admin-rest-api/index.html#/database

But how could the client tell the difference between no change and removed if its not present in the list?
Much like delete there needs to be something in the list to know to remove it.
If something is removed from a users channel then i’d have thought there’d be something to indicate, but perhaps this is something unique to sync gateway and channels not DCP.

Currently looking at holding the channels to which a user belongs on the client and checking to see if the channel list in the doc contains any channels otherwise its an ‘out of view’ situation.

When i faced such a situation, what i decided to do was to change the document type from x to old_x. This helped those documents to be automatically excluded by the view. Changing the type field might not work for you, but a similar field change could. Channels are just tags, hence if any view or query has to consider it, this has to be specifically coded in.