Design Query Regarding Database Syncronisation


#1

Hi,

I’m currently trying to design a system which is ultimately talking to a Mongo database in the cloud, with local android devices using the realm database and it automatically syncing back to the cloud. Brilliant so far… the flaw in the design is that where these devices are located it may on occasion loose connection to the cloud and these devices need to continue, which is still ok, however they still need to sync with each other in the location as a typical user may do something on one device and then later do something else on another device and neither database don’t know about each event, so the question is:

Is it possible to sync realm databases locally when there is no cloud available, but when the connection to the cloud returns it syncs back to the cloud?

Regards

Paul


#2

I dont really get what do you want to achieve.
What do you mean by " sync with each other in the location "? Its like syncing with other phone in a bluetooth/wifi range, or just save new data in a local db, and upload on the server when the connection is available again?

If the second, then realm actually does that by default. It uses offline first approach, which means that if you open a synced realm locally, and save data in that (regardless on the network availability) it will be synced up to the cloud.

If the first, then you need to build it yourself. I had a project like this, we made a local “network” of phones without internet and send data between them with bonjour (bluetooth device search and wifi data sending).

I hope this helps.