hoodiehq / faq

Frequently asked questions about Hoodie
faq.hood.ie
11 stars 3 forks source link

concurrent editing and conflicts #130

Open tgirod opened 8 years ago

tgirod commented 8 years ago

Hi there. I really like your offline first approarch, with syncing happening behind the curtain, when a connection is available. But I wonder how hoodie handles edition conflicts.

For example, let's say I have two devices A and B using the same service, but A has a sparse connection while B is always online. Now, I use A and modify an object locally (no connection). But before this device can sync with the backend, I edit the same object from B, and the modification gets pushed to the backend right now.

What happens when A connects to the internet and tries to sync ? Do I lose the edit made from A ? or from B ? Do I get a warning and have a chance to resolve the conflict manually ?

gr2m commented 8 years ago

We use CouchDB under the hood, so we have the same conflict handling. No changes ever get lost, but you have to handle conflicts as they occur, either automatically or prompt the user. If you expect lots of edits, avoid conflicts by splitting up big documents into smaller bits. When you google CouchDB conflict managements you fill find a lot of thoughts on strategies for that.

We also discussed an API for conflict management in Hoodie which might be helpful to review? https://github.com/hoodiehq/discussion/issues/87