Couchbase Lite iOS Filter

#1

Hi

I have some documents in my local Couchbase database that each have a channel set like “25”.
On iOS in Objective C I then try to have a filter to ONLY pull the data for that channel down… My goal is to assign a channel ID to each user that signup in the application so that i can only pull there records down as part of sync process.

I try the following:

        _syncPull.filter = @"sync_gateway/channels";
        _syncPull.filterParams = [[NSDictionary alloc] initWithObjectsAndKeys:@"25", @"channels", nil];

But when the sync process run I don’t get any data back.

#2

I fixed my code:

_syncPull.filter = @“sync_gateway/bychannel”;
_syncPull.filterParams = [[NSDictionary alloc] initWithObjectsAndKeys:@“25”, @“channels”, nil];

But still can’t get the documents that have that channel set.
For example:

{
"_sync": {
“rev”: “1-fc096a17b4915b832c09cad0b8aa4a7b”,
“sequence”: 37,
“history”: {
“revs”: [
“1-fc096a17b4915b832c09cad0b8aa4a7b”
],
“parents”: [
-1
],
“bodies”: [
""
],
“channels”: [
“25”
]
},
“time_saved”: “2014-04-12T23:01:09.339547919+02:00”
},
“country_id”: 1,
“documentType”: “TestObject”,
“name”: “Test 5”,
“version”: 1
}

#3

The name of the filter is “sync_gateway/bychannel”.

If you got the wrong name from our docs, please let us know where so we can fix it.

–Jens

#4

What exact version of the Sync Gateway and Couchbase Lite are you running? The document dump you included looks wrong, in a way that reminds me of a bug that’s been fixed.

#5

Couchbase Server Version 2.2.0-837-rel for Mac OSX 64-bit.
Sync Gateway is latest version 1.0 Beta3.1 Release

#6

I upgraded to latest Couchbase server 2.5.1 and latest Sync Gateway from Github that I build manually.
Still having this issue. Document below where I want to filter the pull request from Objective C iOS to 28.

My code:

        _syncPull.filter = @"sync_gateway/bychannel";
        _syncPull.filterParams = [[NSDictionary alloc] initWithObjectsAndKeys:@"28", @"channels", nil];

{
"_sync": {
“rev”: “1-13e5af57ebed82c7809d2c57c8fcd9d5”,
“sequence”: 1,
“history”: {
“revs”: [
“1-13e5af57ebed82c7809d2c57c8fcd9d5”
],
“parents”: [
-1
],
“bodies”: [
""
],
“channels”: [
“28”
]
},
“time_saved”: “2014-04-13T08:46:59.858931865+02:00”
},
“country_id”: 1,
“documentType”: “TestObject”,
“name”: “Channel Test 1”,
“version”: 1
}

I did notice the following error in the sync gateway console:

08:47:25.552599 WARNING: Error unmarshaling doc “74C5D497-2F65-499F-BF72-6BCC6316307C”: json: cannot unmarshal string into Go value of type []string – db.(*document).Unmar

#7

Hi
Can you please advise regarding this issue if it is resolved in the latest Sync Gateway etc?

#8

We can’t provide support for obsolete beta builds of our software. Please upgrade to beta 3.1 and let us know if it persists.

#9

Hi Jens
I use latest version of Couchbase Server 2.5.1 from couch base.com and latest version of Sync Gateway from Github.

#10

Sorry, didn’t see this till now. Please file a bug report on Github — it’s much easier to track issues there.