Best way to structure my realms

cloud

#1

hi, I transfer my time-tracker app to realm. I’m not sure whats the best way to structure the realms.
currently the app works as follows:

A user can create an account and create a team. The user can manage projects and has access to the others worktimes from the user.

A worker can create an account and connect to the team (over a accesscode).
he just can select the project and add the time he worked on.

now how i structure my realms?
1.
/timetracker/ with the classes projects / worktimes
2.
/timetracker/common with classes of teams / projects / worktimes
3.
/timetracker/common with classes of teams / projects
/timetracker/~/ with class worktime

thanks for your help


#2

I am not sure there’s enough info here to to understand the use case. Moreover, you don’t really structure Realm - you structure the properties of the Realm Objects stored in Realm.

So for example say you have a Realm UserClass

class UserClass: Object {
   @objc dynamic var user_name  = ""
   let teams = LinkingObjects(fromType: TeamClass.self, property: "users")
}

and you have a TeamClass which can have multiple users

class TeamClass: Object {
    @objc dynamic var team_name  = ""
    var members: user
    let users = List<UserClass>()
}

you could then have projects which links a project to a team or number of teams, which therfore links to specific users.

class ProjectClass: Object {
     @objc dynamic var project_name  = ""
      let teams = List<TeamClass>()
}

You could include a worktimes object within the project class which would track a particular worktime to a user.

As you can see through - there are about 1000 different ways to structure your objects to do what you want.