Multiple areas with multiple data models

Can two different spheres be created, each using a different data model?

For example: defaultRealm will use the client class as a model, and myRealm will use the product class as a model

+6
source share
2 answers

The presence of a different set of Object subclasses in each Realm is not yet supported, but it will be https://github.com/realm/realm-cocoa/issues/1584 .

+2
source

As in the case of Realm Swift v0.95.0, the set of classes of the specified Realm stores can be set using 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 when realmB can only store an instance of Product .

+11
source

Source: https://habr.com/ru/post/988042/


All Articles