With using Couchbase lite, I am having a typical scenario. Where merge would have to happen after document creation and not after update.
A typical user is identified by its information in the document with its email id as the doc _id. User may or may not be registered.
Though app is able to work offline, User A creates a new List A which is shared with userB@abcd.com that is already registered by getting the user’s email from its local contacts.
So it will create a document with the email address in id as u::userB@abcd.com. And the data was also modified 2-3 times. So it will contain rev id starting from 4.
Now as userB@abcd.com is already registered, it will already have a document on server with same id.
When the internet connection is available this tries to sync by getting the revision no, it finds that userB@abcd.com in the local of user A is having higher rev id. So it will override the user’s original data by the data which was aquired by the local contact book.
How can I avoid this situation where documents are generated with the same id at different devices.?
The other thing is is there any way to give 2 different ids to the same document? So that I can identify the same user even offline having different email ids. Like if userB having userB1@abcd.com and userB2@abcd.com but should point to the same user account.