Filtering pull request by user and channel

37 views
Skip to first unread message

Victor Fernandez

unread,
May 21, 2015, 11:52:23 AM5/21/15
to mobile-c...@googlegroups.com
Hi
I'm working with Couchbase Lite for iOS (Objective-c), my app have a communication with a Sync Gateway. In the sync function (server side) I have been filtering the documents by certain parameters and order them in different channels. 
In the iOS app I am creating a CBLReplication object with pull request filtered by channel name despite of this the app is pulling all the documents without restrictions. So maybe I need to filter the pull request also by username but I can't find any documentation about this.
Could anyone give some example? 

Thanks a lot! 

Jens Alfke

unread,
May 21, 2015, 11:56:32 AM5/21/15
to mobile-c...@googlegroups.com

On May 21, 2015, at 8:52 AM, Victor Fernandez <vfern...@txmglobal.com> wrote:

In the iOS app I am creating a CBLReplication object with pull request filtered by channel name despite of this the app is pulling all the documents without restrictions. So maybe I need to filter the pull request also by username but I can't find any documentation about this.

Only by-channel filtering is supported. If it’s not working correctly for you, we should investigate that. Can you give more details about what’s going wrong? (I’m guessing that your sync function isn’t correctly assigning documents to channels.)

—Jens

Victor Fernandez

unread,
May 21, 2015, 12:18:41 PM5/21/15
to mobile-c...@googlegroups.com
Hi Jens
I'm doing this in my sync function
 if(doc.date!=actualDateString){
     console.log("This document must not be synchronized");
     channel("x");
      access("x","x");
 }else{           
    channel("local");
    access("local","local");
 }

I already test the if/else and it's working fine. In the iOS app I'm doing this
self.pullGateway.filter=@"sync_gateway/bychannel";
self.pullGateway.filterParams=[[NSDictionary alloc] initWithObjectsAndKeys:@"local", @"channels", nil];
self.pushGateway = [self.database createPushReplication: self.gatewayURL];


The result is the same, whit or whitout channel filtering. I'm having the same number of synchronized documents.

Jens Alfke

unread,
May 21, 2015, 12:53:10 PM5/21/15
to mobile-c...@googlegroups.com

On May 21, 2015, at 9:18 AM, Victor Fernandez <vfern...@txmglobal.com> wrote:

self.pullGateway.filter=@"sync_gateway/bychannel";
self.pullGateway.filterParams=[[NSDictionary alloc] initWithObjectsAndKeys:@"local", @"channels", nil];

The preferred way to do this is
self.pullGateway.channels = @[@“local”];
although what you’re doing should be equivalent.

I don’t see anything obviously wrong, so I’m going to be nit-picky and ask whether you’re certain that self.pullGateway is non-nil at the time the above lines execute (it’s not clear from context since you didn’t actually show the line that initializes it.) I’ve been bitten by this sort of issue many times.

—Jens

Victor Fernandez

unread,
May 21, 2015, 1:15:58 PM5/21/15
to mobile-c...@googlegroups.com
No, I don't think that the object is nil. This is the complete block
self.pullGateway = [self.database createPullReplication: self.gatewayURL];
self.pullGateway.filter=@"sync_gateway/bychannel";
self.pullGateway.filterParams=[[NSDictionary alloc] initWithObjectsAndKeys:@"x", @"channels", nil];

self.pushGateway = [self.database createPushReplication: self.gatewayURL];
self.pullGateway.continuous = YES;

self.database it's obviously an object CBLDatabase

ajres

unread,
May 21, 2015, 1:31:39 PM5/21/15
to mobile-c...@googlegroups.com
Is the self.gatewayURL accessing the Public REST API on port :4984 and not the admin port on :4985?

Andy

Victor Fernandez

unread,
May 21, 2015, 1:55:43 PM5/21/15
to mobile-c...@googlegroups.com
Yeah sure, the connection is with the port 4984
Reply all
Reply to author
Forward
0 new messages