Does sync gateway channel filtering return only immediate channels?


#1

Does sync gateway (1.1.0) channel filtering only return the channels a document currently has, or does it include channels a document previously had but no longer has? E.g. I have a document with this _sync object:

"_sync": {
       "rev": "1-8b25bf002244971c4784b5ec5bfe5b40",
       "sequence": 1019465,
       "history": {
           "revs": [
               "1-8b25bf002244971c4784b5ec5bfe5b40"
           ],
           "parents": [
               -1
           ],
           "bodies": [
               ""
           ],
           "channels": [
               [
                   "00011742-0c5c-49a3-97e8-ac422b4bc09e_1115",
                   "user_00011742-0c5c-49a3-97e8-ac422b4bc09e",
                   "write_user_00011742-0c5c-49a3-97e8-ac422b4bc09e"
               ]
           ]
       },
       "channels": {
           "00011742-0c5c-49a3-97e8-ac422b4bc09e_0000": {
               "seq": 1019465,
               "rev": "1-8b25bf002244971c4784b5ec5bfe5b40"
           },
           "00011742-0c5c-49a3-97e8-ac422b4bc09e_1115": null,
           "user_00011742-0c5c-49a3-97e8-ac422b4bc09e": null,
           "write_user_00011742-0c5c-49a3-97e8-ac422b4bc09e": null
       },
       "time_saved": "2015-03-19T14:03:09.4924625Z"
   }

When we sync from couchbase lite ios client (1.0.4) with a channel filter of [ “00011742-0c5c-49a3-97e8-ac422b4bc09e_0000”] it is retrieving the above document. Is this expected since that channel is tagged for the current rev, or is it an error since the document no longer has that channel.


#2

When a document is removed from a channel, that revision of the document is still accessible via the channel, but is marked as removed/deleted. This is to support notification of clients that they no longer have access to the document.

Your synchronization from Couchbase Lite should be see that document in the _changes feed with a _deleted flag, to indicate that the document has been removed. The client shouldn’t be able to retrieve the full body of that document, though.