问题
What is the recommended way of dealing with multiple PouchDB instances in the browser that synchronize simultaneously with the same remote/local database?
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.
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
}
Do I need to ensure that only one PouchDB instance syncs at a time and pass changes around manually?
回答1:
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. :)
来源:https://stackoverflow.com/questions/29173889/how-to-handle-multiple-pouchdb-instances-in-the-browser-that-sync-with-the-same