The partition key is the ‘name’ of a Realm - both on the server and locally as well. If you look at the actual Realm filenames, they are the specific name of the partition
Partition Values
Each unique partition value, or value of a partition key, maps to a different realm. Documents that share the same partition value belong to the same realm. All documents in a realm share the same read and write permissions.
As far as the client SDK goes, no that can’t directly be done.
So if your object looks like this
class TaskClass: Object {
@objc dynamic var _id = ObjectId.generate()
@objc dynamic var _partitionKey = ""
}
and the _partitionKey is
"owner=julien,category=cat_a"
there will be a local filename matching that string
%22owner%3Djulien%2Ccategory%3Dcat_a%22
When creating the connection to Realm, the _partitionKey would have to match that
let config = user.configuration(partitionValue: "owner=julien,category=cat_a")
Realm.asyncOpen(configuration: config) { result in
Otherwise Realm wouldn’t know which file to open.
I would suggest changing the object structure to have the category as a property
class TaskClass: Object {
@objc dynamic var _id =
@objc dynamic var _partitionKey = "" //the users uid
@objc dynamic var category = ""
}
If the categories are hard coded or stored in a list, you could concatenate the category with the owners id to have them all open at one time - that would give you access to all of them but they would each be in separate Results objects.
One other option is to denormalize your data - essentially keeping duplicate data in another Realm using the users uid as the _partitionKey. Upside is you can query across all categories (if that is the use case) but downside is more code to maintain and duplicate data.