I built my Firebase database as flat as possible.
This is my structure: https://stackoverflow.com/a/40115527/3669981
with a little adjustment: Instead of role values in my projectsRoles
node I'm using the role keys assigned to the /roles
node (So I can add and edit roles easier).
The pain starts when I need to make 1 + (numUsers*2)
Calls in order to get a project member list, assuming I already have the project ID.
- Call to
projectsRoles/$projectID
to get all user IDS of the current project. - Loop each USER ID+Role ID received:
- Get the role name by
roles/$roleID
- get user information by
users/$userID
- Get the role name by
That means if a project will have 30 members, the app will make 61 calls to firebase database.
My question is: Although the number of calls is high, the data received each call is minimal. I followed the instruction to make is as flat as possible, But is it common to make so much calls to firebase?