【问题标题】:Data not syncing between CouchDB and PouchDBCouchDB 和 PouchDB 之间的数据不同步
【发布时间】:2015-07-20 20:29:34
【问题描述】:

我正在尝试使用客户端上的 PouchDB 和服务器上的 CouchDB 构建一个具有双向复制的基本应用程序。

在我拥有的客户端上:

db = new PouchDB('mydb');
.
.
.
sync = db.sync('mydb', 'http://localhost:5984/mydb', {
  live: true,
  retry: true
}); // .on() calls left out for brevity, but they are in the code and they are firing

我有一个 CouchDB 服务器在指定的 url 上运行。 curling url 提供了预期的响应。但是,没有 PouchDB 上的数据被“推送”到服务器 CouchDB。预期的事件正在触发,但没有数据被持久化到服务器。在“更改”事件中,我得到以下信息:

doc_write_failures: 0
docs: Array[0]
docs_read: 0
docs_written: 0
errors: Array[0]

目前,我正在尝试与 CouchDB 同步的 PouchDB 数据库中有两个文档。向 PouchDB 添加新数据不会触发同步。

有什么想法吗?我被难住了……

编辑

当我将sync() 调用更改为以下内容时:

sync = db.sync('http://localhost:5984/mydb', ...)

我在 js 控制台收到如下错误:

http://localhost:5984/mydb/?_nonce=1437507025317 net::ERR_FAILED

【问题讨论】:

  • 我认为你应该在那边的第一行交换 PouchDB 和 CouchDB。
  • 已编辑。谢谢

标签: couchdb pouchdb html5-appcache application-cache


【解决方案1】:

事实证明,问题在于我使用的是 appcache api,而我的清单文件没有引用网络部分中的服务器数据库。

类似问题here

【讨论】:

    【解决方案2】:

    您是否在 CouchDB 上启用了 CORS? https://github.com/pouchdb/add-cors-to-couchdb

    【讨论】:

    • 是的,我做到了。我看到我的 CORS 设置为:credentials: trueheaders: accept, authorization, content-type, origin, referer, x-csrf-tokenmethods:GET, PUT, POST, HEAD, DELETEorigins: *。此外,我没有收到任何指示问题的错误。根本没有同步数据。
    猜你喜欢
    • 2015-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-02
    • 1970-01-01
    相关资源
    最近更新 更多