SG - filter by channel works with arrays only

#1

Found something interesting that some people might get tripped up on.

I used the default sync function:

function(doc){
channels(doc.channels)
}

I added the below document into SG with "channels":"bob"

{
"_id":“12345”,
“channels”:“bob”
}

And when I tried to filter by channel via

http://hostname:4984/{db}/_changes?filter=sync_gateway/bychannel&channels=bob
it returned an empty array

When I tried http://hostname:4984/{db}/_changes?filter=sync_gateway/bychannel&channels=*
with a “*” , it worked but I got all the documents in the DB.

But when I changed it to "channels":["bob"] an array everything worked fine :+1: and filters by only docs in the “bob” channel.
{
"_id":“12345”,
“channels”:[“bob”]
}

It accepts one or more arguments, each of which must be a channel name string, or an array of strings.

In the docs when it talks about channels( ) its not that clear about arrays and filter by array only or is that a bug?

Source: http://developer.couchbase.com/documentation/mobile/1.2/develop/guides/sync-gateway/sync-function-api-guide/routing/index.html

#2

This looks like a bug to me - the channel() function is supposed to support both cases, as documented.

@househippo Can you file a github issue for this?