I have two Realm files configured in my app. I want to store my Log model to a separate file from the rest of my models. My problem is that I also see my Log model class in my default Realm file, which I don't want. How can I exclude a particular model class from a given Realm file?
I use the default configuration for my main Realm file, and I want to store the Log model only in another database file, but when I default.realm in the Realm Browser it also shows the Log model.

You can explicitly list the classes a given Realm can store via the objectTypes property on Realm.Configuration:
let configA = Realm.Configuration(fileURL: realmFileURL,
objectTypes: [Dog.self, Owner.self])
let realmA = Realm(configuration: configA)
let configB = Realm.Configuration(fileURL: otherRealmFileURL,
objectTypes: [Log.self])
let realmB = Realm(configuration: configB)
realmA can only store instances of Dog and Owner, while realmB can only store instance of Log.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With