Synchronize multiple local database with a remote central database

hi everyone! so I need your proposals to face my problem :slight_smile: I throw myself into the water , let’s go!
i have a remote central database that must contain all records coming from using a application by many clients! the application save data in local firsteble then save data in remote database ! we’re good until now… the problem persist when we go in offline mode (no internet) so lets suppose that we have a remote db central 2 clients : client A and client B => local database A + local database B (the two databases are independent) . we are offline ! i have create a record rec1 in the DB -A and record rec2 in the DB -B . opppa
online mode is active so the db A must push the rec1 in DB central also the db B must push the rec2 in DB central :
____________________Central DB
_______________________ rec 1
_______________________ rec 2
DB A --------------------------| |----------------------------------DB B
rec1 _______________________________________________ rec 2

when im using replica set data will be inserted everywhere and that is my problem !!!
primary(db master) will synchronize with secondary databases(db slaves)
i don’t want that the DB-A data to be inserted into the DB-B and vice versa !

1 Like

Hi @spoke996,

I actually tried to do this in MongoDB World Hackathon 2019. You could do automatic sync between your local databases and your central database, even after your device goes offline.

I did it with MongoDB Mobile, which was a part of legacy MongoDB Stitch but currently I guess MongoDB Realm provides this sync, and sync configurations. Maybe @Drew_DiPalma might be able to help you with this more.

Documentation - MongoDB Realm Sync

Documentation of Legacy MongoDB Mobile

@shrey_batra thank you for your return ! @Drew_DiPalma can you help me about this problem?

Hi – It might help to get a little more information about your use case, but this seems like a place where you would use Sync and create a Partition Key that separated your data by user (so that rec A / rec B can live within the same backend database but are not shared by users). If you need to duplicate/move data between rec A/rec B you may also want to look at Triggers for this use case.