Updating locally created document with document from the CB Server


When creating a local document on a device with a known ID that will eventually be created on the CB Server (after some business logic and API results), should the newly created document on the CB server be synced with the local document on the device (providing it has the same CB id)?

Secondly, do all the properties on the doc need to be exactly the same? i.e The locally created document has an a property that is specific to the device such as a locally stored file location.


Local doc:

val doc = MutableDocument(id123)doc.setString("downloadUrl", "") doc.setString("localUri", localUri) doc.setString("type", attachment) database.save(doc)

returned doc from CB server when ready
{ id: id123 downloadUrl: "https://exampleurl" type: "attachment" }

I was hoping by to have the documents synced and merged?

If you create a document with same Id on the client and server when they are disconnected from each other (i.e they are not syncing with each other), then the next time they try to sync, there will be a conflict. System will auto resolve conflict for you or you can define your own custom conflict resolver. You can read about conflict resolution here

1 Like