我正在将最新的Couchbase服务器与Sync Gateway一起使用。在客户端应用程序上,我快速推送如下文档:
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}得到了对rev的错误响应 -YFzAmAK0VWolQcrIv2DiWH 1-a82becb9eacf1c02d0514aeb7f97cfcef9816bda(序列号4):HTTP 500'JS同步功能中的异常'
我没有错误了,但是服务器上的频道仍然为空:(
答案 0 :(得分:2)
我发现我正在与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
不需要用户级别的同步功能。