I am creating doc with
document id A and assign it to channel C1 in sync gateway with state property value as S1.
Now on server side, listening to _changes feed to process the doc and changing the state from S1 to S2 and assign that doc to only channel C2.
Problem is the new revision still appears in channel C1 feed. Is there anyway I can remove that doc from Channel C1 so that it no longer appears in _changes feed of that channel?
The document will be in whatever channels your sync function added it to. Every time it’s updated, the sync function is called and every channel() call made by the sync function re-adds the doc to that channel. It will no longer be in any channels that it isn’t re-added to by the sync function.
So in short, if you don’t want it to be in channel C1 anymore, modify your sync function so that when the doc is in state S2 it isn’t added to C1.
I am already doing exactly what you suggested.
Please find below sync function snippet. I am creating event with toBeCreated state and and once it is created I am no longer keeping it in “toBeCreated” channel it still shows in that channel.
I dont want to include the processed doc in _changes feed if it is removed from that channel. Currently it includes all docs removed from particular channel with removed key as you mentioned.
So If I want that _changes feed should not have the processed doc (Doc which moved from toBeCreated to created state and moved out of channel toBeCreated) then I should remember that last process sequence number and put it in since query param.