Resolve Pouch Couch DB

回眸只為那壹抹淺笑 提交于 2019-12-23 16:18:32

问题


I am developing a prototype website that works offline that utilises Pouch DB so that it syncs back up to a CouchDB on a server when it goes online.

The Pouch DB conflicts guide says:

To resolve the conflict, you simpy put() a new revision on top of the current winner.

How do you do this? I have the tried the following functions but neither work as expected:

function (current, chosen) {
    chosen._rev = current._rev;
    chosen._conflicts = [];
    db.put(chosen);
};

function (chosen) {;
    db.put(chosen);
};

The top function takes two documents:

  • The document that is the current winner
  • The document the user has selected to become the new winner.

I've read in some places (like here) that deleting the losing conflicts is necessary but I would rather not delete anything if possible, and the Pouch DB guide has no mention of this.


回答1:


You're right; you need to delete the losing conflicts (as unsavory as that sounds). I made a mistake when I wrote the guide; the conflicts will still exist unless you delete them.

By the way, deleting the conflicting revisions just means adding a "tombstone" on top of them. So really nothing is being "deleted" unless you explicitly compact your database. This is the case with both PouchDB and CouchDB.

Edit: I fixed the docs. In any case, could you please update the guide to reflect that fact that you need to delete any unwanted conflicting revisions? We love pull requests, especially from folks who have dealt with this kind of stuff first-hand! :) The document that needs to be modified is this one.



来源:https://stackoverflow.com/questions/27193171/resolve-pouch-couch-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!