How do i do this in realm react-native? Im trying to sync specific data in specific databases within the cluster in mongoDB Atlas, but it goes to a default database.
Also how do i configure 2 different databases. Let’s say i have “Purchases” database, and this database needs to update the “Clients” database and “Product” database. I know how to do this with mongoose but not with realm
Hi, when using developer mode to populate schemas, all tables are mapped to “defaultDBName.realmTableName”. If you want to map realm tables to specific database/collections, you can do so by setting this in the “Schemas” configuration in the UI.
I think this page is perhaps good to read through. If you have any other questions about it after reading through it, please let me know and I would be happy to assist.
Hi, to change the mapping from Realm Table to MongoDB Namespace you need to configure the App Services application at realm.mongodb.com. See this screenshot:
I have created an app, it’s fully functional, with users, schemas, rules, etc.
My problem is, as you can see in the image below, I have a database named shop, with a collection named products, but when I sync, my objects go to a database named todo, but I want to specifically send them to shop.
I understand that this is because my sync settings in app services is set to development mode where you can specify a default database. But I want to pick specifically where my objects should be stored, and not default to a random database.
That’s very clear, i will do that now, thank you. But what happens, if I have two databases with the same collection and schema, how would it know which collection to sync to?
I will give you my real app scenario, given this is just a demo for me to try and work this out:
I’m building an app for hospital wards, each ward will have their own database, each database it’s own “patient” collection, among other collections with the exact same name. So you may have:
Are you trying to use sync or just the Remote Data Access built into the SDK’s? If you are trying to use sync that is not currently possible. Its worth mentioning that generally having databases per customer is an anti-pattern and you should try to use a single DB / Collection with a “ward_id” field or something like that.
So how would you structure this database, would you have all the patients, staff and all other info within the same database? so for example, the “patients” collection will hold all the patients for all the wards?
Also, say we have have 4 hospitals, each hospital has about 8 to 10 wards, each ward has around 25 patients, would you still recommend having everything in the same database.
The app is to be used in hospitals, I will need to sync data because you may not always have an internet connection, so I need the app to work online and off.
Hi, I would recommend having a single collection that holds the documents for all hospitals/users. I think this is a good documentation summary of how to think of multi-tenant architecture in MongoDB.