According to the documentation “Realm clients should never modify the partition value directly”
This suggests to me that the partition should be set upon object creation and never modified. Do I understand that correctly?
If so, what is the best practice for handling partition changes?
Here’s a scenario:
User creates a document.
If I set the partition of these documents to the _id of the user who created them, we can easily open a realm on that _id and synch is straightforward.
Now, what if I want to allow another user to synch that document?
Given that I cannot (or should not?) modify the partition after it has been created…
Would this partitioning strategy work?
Set the partition on the document to something like this on creation:
author=1234&reader=4321editor=1243
And maintain keys on the user document for reading and editing which reference lists of all of the reader or editor id’s that a user has been invited to.
So, when a user shares a document, I would register id’s to the user documents…
Something like this, for instance:
reading = [4321]
Then, for the user which has been invited to read the document, I would open a realm on the partition:
reader=4321
The problem here, as I understand it, is that, if a user is invited to read a lot of documents, I potentially have to open a ton of realms.
Is there a better strategy for this type of schema?