Structure of Realms with User / Team Management

hi,
I have following setup:
My users could login via jwt-token. Then I have /common-realm with two classes: User and Team.

There I store all user and team details. Every user could be in more then one team. Then for every Team there exist a /team-realm-x.

My first question: Is that the correct way to do this?

My second question: At the moment I have to use query based realm for the common-realm. Which I read is not the best way to use in production. How can i structure my realms better? Also is it safe to use query based realm? or would it be possible for a user to query the others user / teams in the common realm?

Thanks for your inputs!

Update:

i now create for every user a personal realm (full-sync). For the team a create with an administrator a team realm on the root (like /TeamId/). With the permission i can only let the team-members read the profile realm from the user.

Now i have a view with the team-members and i like to observer any changes on the profile realms. For that i have to observe multiple realms at the same time, wich seems that it won’t work. Is that true? Is it not possible to make an array with notificationtokes for observing objects from different realms?

thank you!

@rouuuge You need an observation per realm, but there’s no reason you couldn’t put all those tokens in one array. For example, something like this:

let realms = [...]; let tokens = realms.map { $0.objects(ObjectType.self).observe { change in ... } }

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