Problem with simple Sync config

I have problem with simple sync configuration for Xamarin app. I guess I’m missed something but after many hours I still can’t find solution.

I need simple collection all can read and add documents, but only owners can edit their documents.

How to configure it?

That question is overly vague and the best we can do is point you to the docs. Can you clarify what is it that you tried and how it didn’t work? Did you try the quick start example?

Thanks for the quick reply and sorry for the little detailed question. Yes, I looked through these documents before but found no answer there (maybe I missed something).

I’m trying to migrate app from Realm Cloud to MongoDB, everything works very nice, except permissions.

It is little more complicated in real life but to explain simpler I have collection of 20 000 documents. Each document has different owner, everyone can read all documents, and everyone can add new document, but only owners can edit their documents.

In Realm Cloud app I could manage it with object level permissions, but now permissions works different.

First I tried to put all documents into one Partition and create “owner” and “non-owner” role with permissions, but it seems when Sync is enabled permissions are managed “on the synced cluster”.

Then I tried to setup permissions there, but I can’t find a way how to configure it correctly. If I set different Partition for each user, users can see only own documents because when I open

var realm = Realm.GetInstance(new SyncConfiguration($"{RealmApp.CurrentUser.Id}", RealmApp.CurrentUser));

only documents from one partition are synchronised, but if I put all data in one Partition , everyone have full access.

Do I need to redesign everything and use for example functions to add/update documents or there is a way to set object level permissions?

@Radoslaw_Kubas There are no object level permissions with new Realm Sync - only partition/realm level permissions of read or read/write. To accomplish what you’re suggesting I’d have two realms - one for each user where they are the owner of the documents and one global realm - which would have a read-only copy of all documents. You could use Realm Triggers - https://docs.mongodb.com/realm/triggers/database-triggers/
to replicate any changes an owner makes from their private-per-user realm to the global realm.

I hope this helps

2 Likes

@Ian_Ward Thank you very much for the hint :slight_smile:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.