Is it possible to create two different realms each one using a different data model?
For example: defaultRealm would use the client class as model and myRealm would use products class as model
As of Realm Swift v0.95.0, the set of classes a given Realm stores can be set 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: [Product.self])
let realmB = Realm(configuration: configB)
realmA
can only store instances of Dog
and Owner
, while realmB
can only store instance of Product
.
Having a different set of Object
subclasses in each Realm isn't yet supported, but it will come with https://github.com/realm/realm-cocoa/issues/1584.
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