【发布时间】:2018-08-23 08:19:29
【问题描述】:
我正在尝试通过通道同步网关将 pouchDB 与 CouchBase 同步。 在袋子里我有:
var da = new PouchDB('example_DE');
da.sync(remoteDB, {
create_target: true,
live: true,
retry: true,
filter: "sync_gateway/bychannel",
query_params: {
channels: ["DE"]
}
})
同步配置文件:
{
"log": ["*"],
"CORS": {
"Origin":["http://127.0.0.1:8887","http://localhost:8887"],
"LoginOrigin":["http://127.0.0.1:8887","http://localhost:8887"],
"Headers":["Content-Type","Authorization"],
"MaxAge": 1728000
},
"adminInterface": "127.0.0.1:4985",
"interface": "0.0.0.0:4984",
"databases": {
"db": {
"bucket":"db",
"username": "Administrator",
"password": "123456",
"server": "http://localhost:8091",
"sync":
`function (doc) {
channel(doc.channels);
}
`,
"users": {
"GUEST": {"disabled": false, "admin_channels": ["*"] }
}
}
}
我可以在 IndexedDB 的浏览器中找到我的文档,但在控制台中我收到此错误: 获取http://localhost:4984/db/_local/nKlC5IrimnHOiQZcwE_LYA%3D%3D? 404(未找到)
【问题讨论】:
-
您使用的是什么版本的 Pouch、Sync Gateway 和 Couchbase Server?
-
PouchDB - 6.4.3,同步网关 - 1.5,Couhbase 服务器 - 社区版 5.0.1
-
我怀疑这里有两个问题。首先,如果我正确理解 PouchDB 选项,那么您要求的是基于设计文档的服务器端过滤器。您是否在 Sync Gateway 中设置了设计文档?这可能是 404 错误的原因。其次,过滤复制存在兼容性问题。我不知道这是否会影响你的情况。您可以在此处阅读有关该问题的信息:github.com/couchbase/couchbase-lite-ios/issues/1139
-
设置设计文档是什么意思?我可以在管理界面的 Sync Gateway 中看到文档
-
进一步审查,我认为我错了。您似乎使用了错误的端点来检索文档。如果它已经从 PouchDB 同步,它应该是localhost:4984/db/doc_id。请参阅developer.couchbase.com/documentation/mobile/1.5/references/… _local 用于特殊用途的文档。按照设计,它们不会被复制。 (仅供参考设计文档,请参阅:developer.couchbase.com/documentation/mobile/1.4/guides/…)
标签: couchbase pouchdb couchbase-sync-gateway