通过通道同步网关将PouchDb与CouchBase同步 - 本地文档的错误404

时间:2018-03-14 17:14:22

标签: couchbase pouchdb couchbase-sync-gateway

我正在尝试通过渠道同步网关将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的浏览器中找到我的文档,但在控制台中我收到此错误: GET http://localhost:4984/db/_local/nKlC5IrimnHOiQZcwE_LYA%3D%3D? 404(未找到)

1 个答案:

答案 0 :(得分:0)

这是无需删除“ sync_gateway / bychannel”的方法:

var local = new PouchDB("yep");
var remote = new PouchDB("http://user:password@localhost:4984/bucket/");

// sync starts here
local.replicate.from(remote, {
    filter: "sync_gateway/bychannel",
    query_params: {
        channels: ["DE"]
    }
});