Trouble in changing access of doc's channel

14 views
Skip to first unread message

atom992

unread,
May 18, 2015, 9:32:21 AM5/18/15
to mobile-c...@googlegroups.com
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)?



ajres

unread,
May 18, 2015, 10:23:57 AM5/18/15
to mobile-c...@googlegroups.com
@atom992

If you started a new sync after you changed docC you should only get docB and docC.

If you ran sync from the start then once docA has been sync'd to the client it will not be removed if the user looses access to the channel it was originally pulled from.

There is a ticket describing this behaviour [here](https://github.com/couchbase/sync_gateway/issues/264)

Andy

atom992

unread,
May 18, 2015, 1:07:04 PM5/18/15
to mobile-c...@googlegroups.com
Thank you very much.
Reply all
Reply to author
Forward
0 new messages