> On Jul 22, 2015, at 10:37 PM, Daniel Sonny Agliardi <[email protected]> wrote:
> 
> There is a way to find out the reason 409 error in my code? The UPDATE seems 
> pretty easy to understand (getting document, extract properties, update 
> locally the properties, and put properties back in document).

A conflict error happens when you try to update a document but the value of the 
_rev property in the dictionary you provide isn’t equal to the _rev property of 
the document on disk. That is, when the revision you’re updating isn’t the 
current revision.

When a document is saved successfully, the _rev property is changed to a new 
unique revision ID before it’s written to disk.

Hopefully that helps you understand the way things work.

Another thing that can cause conflicts is when you hang onto the properties 
dictionary in between updates and try to make two updates using it:
        props = doc.properties.mutableCopy
        props[“x”] = “y”;
        [doc putProperties: props]; —> OK
        …
        props[“a”] = “b”;
        [doc putProperties: props]; —> Conflict
The reason is that when the second putProperties is called, props still has the 
old _rev value, not the updated one from the first save.

—Jens

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/5C7DC192-19B3-4490-B45A-754A3BEC8FCB%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to