-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
Hi guys!
It's good idea is hiding whole crud logic under the hood of property wrappers.
I have faced with issue where I what to use couple of entities which have different realms in single View and I got the app termination because EnvironmentValue is providing an only one realm configuration.
I saw in the code example above this constructor:
@ObservedObject(UserData.self, configuration: ....)
Why it doesn't work? It's so really handy - providing particular configuration as I want.
At the time I have:
@ObservedResults(Account.self) var accounts // use .environment(\.realmConfiguration) implicitly and working properly @ObservedResults( UserPublicData.self, configuration: RealmApp.createConfiguration(user: RealmApp.default.realmUser!, partition: "shared") ) var userPublicData // doesn't work
and it is dropping with:
*** Terminating app due to uncaught exception 'RLMException', reason: 'Object type 'UserPublicData' is not managed by the Realm. If using a custom `objectClasses` / `objectTypes` array in your configuration, add `UserPublicData` to the list of `objectClasses` / `objectTypes`.'
static method of RealmApp:
static func createConfiguration(user:RealmSwift.User, partition: String) -> Realm.Configuration { var configuration = user.configuration(partitionValue: partition) let partitionKey = String(partition.split(separator: "=")[0]) if partitionKey == "account" { configuration.objectTypes = accountObjectTypes } else if partitionKey == "shared" { configuration.objectTypes = [UserPublicData.self] } return configuration }
PS:
Guys, please do something with realm configurations. I what to provide bunch of partition values to retrieve shared entities from any partitions as if it's just one.