With your current data structure you will indeed have to do the two-stepped approach:
- Load the list of group IDs
- Load the metadata (e.g. name) of each group
This is known as a client-side join and is quite common with Firebase.
Alternatively you can duplicate the most important information about each group under each user's groups. E.g.
UserGroups
User1
Group1: "This is the first group"
Group2: "This is the second group"
As you see in this sample we've replace the true
marker with the actual name of the group. The advantage of this is that for a simple use-case you only have to read this list and not do a client-side join. A disadvantage is that you need to decide whether/how to keep the data sync. I wrote an answer with the option for that here: How to write denormalized data in Firebase
Note that your data model is not fully flattened, since you're mixing entity types. I recommend splitting the metadata of each user (their name and description) from the "list of groups that the user belongs to". That leaves you with four top-level lists:
Users
Groups
UserGroups
GroupUsers
This is a common pattern for many-to-many relations, which I further described here: Many to Many relationship in Firebase