Couchbase 接收频道空

Couchbase receive Channel null

我正在使用带有 Sync Gateway 的最新 Couchbase 服务器。在客户端应用程序 swift 我推送这样的文档:

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

在服务器上,我收到了这份文件,但问题是

   "channels": [
        null
      ]

因此,当我尝试通过渠道提取文档时,我收到了 0 个文档。

我这里有一个配置文件:

     {
"log": ["*"],
"adminInterface": ":4985",
"databases": {
  "dev": {
    "num_index_replicas": 0,
      "server":"http://localhost:8091",
      "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"] }
    }
  }

}

}

感谢您的回复。

编辑:

同步功能为

 "sync":
        `function(doc) {channel(doc.channels);}`
      }

我收到错误

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'

我不再有错误,但服务器上的频道仍然为空:(

我找到了连接 nurse1 和 nurse2 的解决方案,所以我必须像这样

添加 function(doc) {channel(doc.channels);} 给这个用户
     "users": { 
      "admin": { "disabled": false, "password": "adminadmin"},
      "nurse2": { "disabled": false, "password": "adminadmin","sync":
        `function(doc) {channel(doc.channels);}`, "admin_channels": ["nurse2", "_nurse2","nurse1", "_nurse1"]},
      "nurse1": { "disabled": false, "password": "adminadmin","sync":
        `function(doc) {channel(doc.channels);}`, "admin_channels": ["nurse1", "_nurse1", "nurse2", "_nurse2"] }
    }

我还必须在像这样保存之前向文档添加频道

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

_________EDIT

不需要用户级别的同步功能。