exclude model class Realm
I have two Realm files configured in my application. I want to save my model Log
to a separate file from the rest of my models. My problem is that I can also see my model class Log
in my default Realm file, which I don't want. How can I exclude a specific model class from a given Realm file?
I am using the default config for my main Realm file and I only want to save the model Log
in another database file, but when I am default.realm
in the Realm browser it also shows the model Log
.
source to share
You can explicitly list the classes for a given scope can store through the property on : objectTypes
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 Dog
and Owner
, whereas realmB
can only store instances Log
.
source to share