Doubts about conflicts in couchbase Lite document handling

Hi ,
I am having doubt regarding conflit,

I have one application which is handled by two users, now
user A put document docA,
user B get docA,
now both are in offline mode,
now user A deletes docA,
and User B updates docA
and now both are online , and syncing started …
What exactly happened on server? is document deleted ? or conflict?

Deletions are not as destructive as you might think, they are simply revisions that are marked in a special way. So, you would have created a conflict. There would be one deleted revision and one non-deleted at the same level. By default, the non deleted revision wins and that is the revision that people will see if they don’t look at the conflicting revisions property.

ok.Thank you.
At the time of updation from many clients , we have to write logic for removal of conflict or Server will automatic takes the winner revision no. for updation?

No matter what you will have only one revision as the current revision. A delete will win over a non-delete, a higher revision number will win over a lower one and at the same level an arbitrary revision ID comparison will decide the winner. If you delete the current winner than the next eligible winner becomes the current revision. If there is no other eligible winner then the document is fully deleted. You don’t necessarily have to write logic to get rid of conflicts if you understand and accept that they will be there and might cause some unexpected behaviour when deleting a document.

thank u so much @borrrden…got the whole concept !!!:+1:

FYI examples of the unexpected behaviours and different resolution methods can be found at (it’s in Swift but applies on all platforms)


That link is unavailable, showing page not found @jamiltz

@shriram.punde I think this is the link @jamiltz intended:

1 Like