Couchbase server receive Channel null

I am using the latest Couchbase Server with Sync Gateway. On the client application swift I push a document like this:

 let userChannel = "\(self.login)"
    config.channels = [userChannel, "zzzz", "nurse1"]
       config.replicatorType = .pushAndPull
    _pushPullRepl = Replicator.init(config: config)

On the server, I receive this document but the problem is that

   "channels": [

So when I try to pull document by channel I receive 0 document.

I have a configuration file here:

"log": ["*"],
"adminInterface": ":4985",
"databases": {
  "dev": {
    "num_index_replicas": 0,
      "bucket": "dev",
       "username": "admin",
       "password": "adminadmin",
      "users": { 
      "admin": { "disabled": false, "password": "adminadmin"},
      "nurse2": { "disabled": false, "password": "adminadmin", "admin_channels": ["nurse2", "_nurse2","nurse1", "_nurse1"]},
      "nurse1": { "disabled": false, "password": "adminadmin", "admin_channels": ["nurse1", "_nurse1", "nurse2", "_nurse2"] }



i add sync fonction

“function(doc) {channel(doc.channels);”

and i’m getting error 2019-02-25 18:07:14.234729+0100 CouchbaseLiteTest[2474:1149779] CouchbaseLite Sync ERROR: {Push#1} Got error response to rev -YFzAmAK0VWolQcrIv2DiWH 1-a82becb9eacf1c02d0514aeb7f97cfcef9816bda (seq #4): HTTP 500 ‘Exception in JS sync function’

_______EDIT ______

    `function(doc) {channel(doc.channels);}`

i don’t have error anymore but channel still null on server :frowning:


Are you adding the “channels” property to the document you create in Couchbase lite?

The replicator config you have in your post is just to filter down the replication to a subset of channels you have access to. It won’t “stamp” those channels into every document you create, you will need to do that when you create the documents.

1 Like

yes i had to set channel for document

  let channels = MutableArrayObject()
            mutableDoc.setArray(channels, forKey: "channels")

thanks for you response