I have highlighted the red line box, the sync part in the above image, The question is how to sync local server MongoDB databases with atlas server databases?
The first thing that comes to mind is change streams. You could build a small app leveraging change stream feature to sync data both ways. Of course, the source and destination would flip depending on which side of the network - limited or unlimited connectivity - you are on. However, there are few caveats to this approach.
First, how do you handle conflicting updates and deletes? Does the chronological order take precedence when deciding the source of truth?
Second, how big should the oplog window be? Definitely greater than the length of lost-connectivity window. But then, how do you handle inserts/updates/deletes bursts which has the potential to overflow oplog before connectivity is achieved?
Anyway, those are some of the things to think about if you go down change-streams path. Hope this helps!
There will be always inserts or updates operations, so it should be executed on the basis of oplog date order,
But yes there will be conflict for some reason the internet is off and some transactions have been made online and some have been made on the local server.
So let me list down the possible queries/operations, I will try to handle there should not be any conflict.