本文介绍了如何处理浏览器中与同一个数据库同步的多个PouchDB实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在浏览器中处理与同一个远程/本地数据库同时同步的多个PouchDB实例的推荐方法是什么?

What is the recommended way of dealing with multiple PouchDB instances in the browser that synchronize simultaneously with the same remote/local database?

我的设置是一个Web应用程序与远程CouchDB连续同步的浏览器。
可以多次打开该Web应用程序(多个选项卡/窗口),从而创建多个尝试同步的PouchDB实例。

My setup is a web application in the browser that synchronizes continuously with a remote CouchDB.That web app could be opened more than once (multiple tabs/windows) and thus create multiple PouchDB instances that try to sync.

在这种情况下,只有一个PouchDB实例将报告远程更改-其他实例在实时同步期间产生冲突:

In such a case, only one PouchDB instance will report remote changes - other instances produce a conflict during live sync:

{
  error: true,
  message: "Document update conflict",
  name: "conflict",
  result: {
    doc_write_failures: 0,
    docs_read: 1,
    docs_written: 1,
    end_time: ...,
    errors: [
      CustomPouchError
    ],
    last_seq: 963,
    ok: false,
    start_time: ...,
    status: "aborting"
  },
  status: 409
}

我是否需要确保一次仅同步一个PouchDB实例并手动传递更改?

Do I need to ensure that only one PouchDB instance syncs at a time and pass changes around manually?

推荐答案

PouchDB复制当前无法在多个选项卡中使用。这是,任何想加入的人都将非常欢迎。 :)

PouchDB replication currently does not work in multiple tabs. It is an open issue, and anybody who wants to hop in would be more than welcome to. :)

这篇关于如何处理浏览器中与同一个数据库同步的多个PouchDB实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 00:20