Connel
Connel

Reputation: 1881

Resolve Pouch Couch DB

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:

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.

Upvotes: 3

Views: 1005

Answers (1)

nlawson
nlawson

Reputation: 11620

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.

Upvotes: 7

Related Questions