Hey, I have a problem that is frustrating me for a long time. It’s a bit long but if you can read that I will be more than thankful.
I have an app, that has users, and each user can create his own “card” which is basically like a digital business card.
The partition of the cards is in the following format: “card=userID”
So I want to be able to share those cards between users. To do so, I am generating a link, that consists of the user ID. So when the app opening the link it just needs to create a new Realm instance with the userID in the partition to get the shared card.
And here the problem starts. I’ve noticed that when I search for cards, it will give a result of 0, meaning a result with no cards, unless the user that created the following partition and card is the one trying to access it. then it does give a result other than 0.
Permissions on the website, in sync settings, are set to “true” for both “read” and “write”.
I’ve also noticed that sometimes it is indeed able to find a card, that the logged user hasn’t created but that’s rare, and makes no sense. why would it sometimes work and sometimes won’t?
Do you know what can the problem be? why it can’t find cards that were not created by the logged user?
How are you opening the other realm/partition? Realm always makes the queries on the local DB copy, that may or may not be fully synchronised with the remote content. If you’re looking at a different user’s data, there may be the need to download the partition itself to a local copy before having it ready, if you don’t give the process enough time to elaborate the remote contents that come in, you won’t get any result. If you’re the user creating the card, then the local DB already contains the reference to it, but a realm updated somewhere else will take time to propagate the changes to you.
Thank you so much for answering!
I understand where the problem can come from.
I tried now to make it download a local copy, but I can’t find how to do that. Can you please let me know how to download the partition?
That quick start tutorial will get you up and running but necessarily omits a lot of details. For your case, I think you’ll want to adjust the code that opens the realm + the configuration that you pass to it. Check out the Open a Synced Realm usage example for some more guidance.