When or why for functions in task tracker sample app?

I am learning Realm/Mongodb and am having some need of understanding why functions were used to add members to a project. Why can you just have a relationship of project with users and do all updates at the client?

@James_Cicenia : Welcome to the Realm community.

This is a very good question, by adding function in this case we get some value additions like

  1. Single source of truth : When you will have multiple platforms like Android, iOS, Web, Unity etc we would have to duplicate the logic of updating information at all end, which violate Single Source of truth principle.

  2. Maintainability: In long run, using function you can avoid common maintainability issues. For example, you will have to make sure that all the client release the update at the same time or else data/application may get corrupted which is easily not possible with mobile app’s.

well what about “off line first” then? How does that function work? It will fail. Correct?

Technically, if I have one platform and codebase, I could add projects to users? or add the user to the a user list in project?

Thank you

Well that’s the beauty of it, the app works the same way all the messages as saved offline, and as soon as you are back online it’s synced automatically with Realm Sync.

“Technically, if I have one platform and codebase, I could add projects to users? or add the user to the a user list in project?” - Yes you can do it but if you are thinking of a long picture I wouldn’t suggest that.

The primary reason why the tutorials/sample apps use functions to control permissions is that given two users, user A shouldn’t be able to change user B’s permissions unless that change is actually just granting user B permission to user A’s project. We use a system function to write without restriction to user B’s custom user data so that users don’t have the ability to arbitrarily write to each other’s custom user data – if that were the case, user A could remove user B’s permission to write to any of his or her granted projects! We use strictly controlled system functions with very limited capabilities based off of the requesting user’s ID to ensure that user A can’t make arbitrary changes to user B’s custom user data.

2 Likes