Hope the title does justice to my question.
Using Current Latest stable Couchbase Server (community) and Sync Gateway Mobile (and counter couchbase lite).
Platform: Server Linux Ubuntu and Client - Xamarin Forms (iOS / Android - .NET SDK)
I have a scenario explaining it as follows:
There are three users in system - UserA, UserB, UserC.
I create one document where we add a property of type list for who are part of this document (its a meeting) - so when I create I add UserA (as he is creating this document on his app) and UserB on to the list.
document.properties.participants = [“UserA”, “UserB”].
I have a sync function which then adds this document to “UserA” and “UserB” channel. This works fine as “UserC” cannot see this document and is not synced to his device.
Now the user wants to change participants who can see or work against this document. So “UserA” updates document.properties.participants as follows:
document.properties.participants = [“UserA”, “UserC”]. This work partially where UserC now sync the document and see the same, but UserB should not see that document and the document should be removed from his sync channel and local SQL lite.
Here is my sync function snapshot:
function (doc, oldDoc) {
var docType = "unknown";
if (doc._deleted) {
docType = oldDoc.type;
}
else {
docType = doc.type;
}
if (docType == 'meeting') {
if (oldDoc == null) {
for(var counter = 0; counter < doc.attendees.length; counter++) {
access(doc.attendees[counter], "sm-" + doc.attendees[counter]);
channel("sm-" + doc.attendees[counter]);
}
}
else {
for(var counter = 0; counter < doc.attendees.length; counter++) {
access(doc.attendees[counter], "sm-" + doc.attendees[counter]);
channel("sm-" + doc.attendees[counter]);
}
}
}
}
I tried using database.compact() to see if that helps on client but has not good results. I can still see the document on UserB’s device.
I am using Push / Pull replications with continous as true in my app on all user’s device.
Really seeking helps to get this sorted and spot the mistake I am doing which I can rectify and move on.
Thanks in advance