Couchbase Light 2.0 Replication - Delete local doc when the channel for the replication (setChannels) is removed from document

Hello,
we are pretty new to couchbase and evaluating it as an replacement for old sync infrastructure in distributed POS project. I saw some posts about deleted and removed channels but could not find a real answer.

Our Problem:
each document gets one or more channels (we name it tag) assigned that represent branches to that the document must be replicated. Devices (Android) in the branches shall use couchbase light and sync with the master database via sync-gateway (1.5) and later also peer to per (if no internet). Now it can happen that a document might not be valid anymore for one branch, so the respective tag is deleted in the main Database.
But the doc is still in the local light database.
What i tried (maybe stupid):
retrieve the _removed key in the query to get all documents with _removed:false so they are not shown in the query results.

My guess was that if i can retrieve _removed:true documents and delete them they also will be deleted at the server. For sure that should not be the case so my idea just to query them out.

My Sync Config looks like:
{
“log”: [""],
“adminInterface”: “0.0.0.0:4985”,
“interface”: “0.0.0.0:4984”,
“databases”: {
“db”: {
“server”: “http://localhost:8091”,
“bucket”:“esaas0000”,
“username”:“fuekor”,
“password”:“password”,
“admin_channels”:[""],
“enable_shared_bucket_access”:true,
“import_docs”:“continuous”,
“users”: {
“GUEST”: {“disabled”: true, “admin_channels”: ["
"]}
},
“unsupported”: {
“replicator_2”:true
},
“sync”: function (doc, oldDoc) { if (doc.tags) { channel(doc.tags); } }
}
},

Any help would be appreciated. Thanks in advance and Greets from Manila

If you are looking to remove the document only from local couchbase lite database and not have that synced to the server, you can use the purgeDocument call in 2.0.

Not sure what CBL platform you are on but this is the docs for swift …and there are equivalent methods on other platforms.
http://docs.couchbase.com/mobile/2.0/couchbase-lite-swift/db021/Classes/Database.html#/s:18CouchbaseLiteSwift8DatabaseC13purgeDocumentyAA0F0CKF

Just a quick note that peer-to-peer is not supported in 2.0. There are plans for it in 2.x .