I’m integrating the MongoRealm into existing iOS App. In this App - I have a Local Writable Realm file with some objects that I don’t wish to participate in Realm Sync as this contains a lot of catalog data.
So I have a used a specific file name based Realm Configuration to initialise the Realm object.
var config = Realm.Configuration(schemaVersion: 83)
guard let fileUrl = config.fileURL else {
throw AppError.invalidState("fileURL of realm config is nil")
}
config.fileURL = fileUrl.deletingLastPathComponent().appendingPathComponent("content.realm")
config.readOnly = false
let realm = try Realm(configuration: config)
With the above - I’m able to see the file created in the documents folder.
I’m also able to create a new object in that Realm using the following definition
class Grade: Object {
@objc dynamic var id=""
@objc dynamic var sno=0
@objc dynamic var name=""
@objc dynamic var version=0
@objc dynamic var timestamp = Date()
let linkedPrimarySkills = List<String>()
override static func primaryKey() -> String? {
return "id"
}
override static func indexedProperties() -> [String] {
return ["sno", "name"]
}
}
And when I query the above realm using the realm.objects(Grade.self) - It returns the object I wrote as expected.
But if I use the find by primary key method to pick a specific object -
let grade3 = realm.object(ofType: Grade.self, forPrimaryKey: "003")
it returns NIL.
Since the above class is NOT part of a Synced Realm - I don’t have a partition key. Also unlike the collections in Synced Realm - I’m using a simple primary key called id. All this code is from Classic Realm usage as a local data store.
So I’m puzzled how this basic functionality is broken ? Is it not possible to have a local (Non-sync) realm co-exist with a sync realm.
Thanks
Ram