Hi,all
I have a trouble in changing access of channel,:
I have three docs:
doc A like this:{"type":"typeA","key":"keyA"}
doc B like this:{"type":"typeB","key":"keyB"}
doc C like this:{"type":"typeC","key":"keyC","refer_id":"keyA","user_id":"user1"}
and one user:user1 with no roles and admin_channels in sync gateway.
following is my sync function(guest user is disabled):
function(doc,oldDoc){
switch(doc.type){
case 'typeC':
channel('u-' + doc.user_id);
access(doc.user_id,'u-' + doc.user_id);
if(doc.refer_id){
access(doc.user_id,'b-' + doc. refer_id);
}
case 'typeA':
if(doc.key){
channel('b-'+doc.key);
}
case 'typeB':
if(doc. key){
channel('b-'+doc.key);
}
}
}
when I send sync from sync to CBL with user1's Cookies, I can get the docA and docC.
but when I changed docC to:
{"type":"typeC","key":"keyC","refer_id":"keyB","user_id":"user1"}
I want to get the docB and docC(docA should not be sync to CBL). but I get docA,docB and docC.
I want to know how can I only get docB and docC when I changed docC(changed refer_id from keyA to keyB)?