-
With regards to the "Upsert" section on https://pouchdb.com/guides/conflicts.html and tell me what it's saying? I don't understand a word of it. E.g., What does it mean when it says "keep repeating put()"? Why would "repeating" put() resolve a conflict?
function myDeltaFunction(doc) {
doc.counter = doc.counter || 0;
doc.counter++;
return doc;
} Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I've got it now! BUT the docs are really unclear / need more explanation in some parts, including this part, IMHO. |
Beta Was this translation helpful? Give feedback.
I've got it now! BUT the docs are really unclear / need more explanation in some parts, including this part, IMHO.
The upsert() retries doing put() "using a different _rev every time" (because it re-gets the document and then retries put()ing. (based on https://github.com/pouchdb/upsert/blob/9c781fc3f623c6f4622afa755b197ced1540c138/dist/pouchdb.upsert.js#L9)
Also the role of the delta function is providing the change as a function, rather than providing the changed document itself. (So that the change remains doable on newer revision of the document as well.)