Relationships and Rules

So if i decide to use the Atlas Device Relationships for Realm and GraphQL there is an open question for me. How are rules and roles applied to this?
For example i have a collection contact with a forgein key to the collection Dataset, how do the rules apply to this. So i have sync rules for the contact that it allows only to read this data as an owner, does this also automaticly include the reference to the dataset? Or do i need to define there additional rules and these one aply than? So because the dataset so far only is allowed to be read an write by the owner.
The owner of the contactdata is a different one then the owenr of the dataset. So does the owner of the contact data know have the permission to read this refernec data or not?

I hope you understand what i mean :slight_smile: and sorry for bad englisch :sweat_smile:

For all services, if you have a cross-collection link then implicitly it is just storing a foreign key to the linking collection. This means that if you query collection 1, you will get all of the primary keys for collection 2 (the one being linked to). For sync, this means that if you query on a collection you will get all of the foreign keys but none of the actual objects that they refer to. The SDK’s will handle this under the hood by letting you know that the list is “empty” in this case and they treat links as null unless they actually have the object being linked to. Therefore, in order to effectively use links you need to query on both collections and have permissions to view both collections (which makes sense since you shouldn’t be able to bypass permissions just because you have a link to an object)

This is why it is often a better fit to use embedded objects when there truly is a “has-a” or “has-many” relationship. However, it still is very possible to use relationships effectively with sync, you just need to have access to both collections.

1 Like

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