How to achieve data loss free in Couchbase mobile lite?

Hi,
We are using Couchbase Lite Mobile 2.1.2 for iOs Swift. we have document like below.

{  
   "type":"store",
   "devices":[  
      {  
         "deviceName":"iPhone X",
         "token":"xxxxx",
         "lastUpdateDate":""
      },
      {  
         "deviceName":"iPhone Xr",
         "token":"xxxxx",
         "lastUpdateDate":""
      },
      {  
         "deviceName":"iPad",
         "token":"xxxxx",
         "lastUpdateDate":""
      }
   ]
}

Here same document was in 3 different devices and each device will updated lastUpdateDate based on the token. But some times few records are updating and few are updating because of auto conflicts fixing.

So is there any way to achieve without data loss and keep all changes in document.
I followed this link and implemented * Option 1 . Merge the conflicting versions of the document and save

Can some one please assist me?

The Option 1 in the blob link is for resolving conflicts that happen during a local save . You cannot override the automatic conflict resolution that would happen during pull replication. So that wouldn’t work for you. Custom conflict resolution is in our radar. Until then, for your needs , I would recommend redesigning your data model so the data is split up into multiple documents - this would avoid the chances of conflicts. So for instance, you would have a single document of “type”: “device” for each device . Each of those documents would be linked to the store document.

I can understand now, so you mean to do like below?

Store Document

{  
   "type":"store",
   "name" : "",
   "address" : ""
}

Device Document, i will store each device like this.

{
  "storeid" : "store document id for maintain relatonship",
  "deviceName" : "",
  "token" : "",
  "lastUpdatedDate": ""
}

I need some more info, if we get message like server rejected error, these docs are really not update into our local until we restart the replication, you can checkthis link

What Priya said – break up documents so that data updated by different devices/clients is in different documents.
What you proposed looks reasonable. What’s the ‘more info’ you need?

I mean sometimes if i update local doc and these are server fxied by automatically(if there is any conflicts), But those are not affecting to server seems it is the cause of replication stopped unexpectedly and when i kill the app and reopen it, it sycn to server. Again it comes to this issue