Realtime DB parent/child

Hi Everyone

I’m trying to create an app which a PT will use to set workouts for their clients. To do this, I’m trying to set up a parent/child structure in realtimeDB.

This way, when a PT logs in, they can create a list view at the PERSONAL TRAINER level so that they can see all of their clients’ details, and add workouts and other data.

If a client logs in, they will see only their data and whatever additional data a PT has set for them.

What I am trying to achieve

The ideal will be -

  1. User is invited to use the app (I want a closed beta initially)
  2. If they’re a returning user, they’ll simply authenticate then go into the app, where they see the data that their user type should have access to
  3. If they’re a new user, their authentication details will be used to set up a new entry into the database at the correct level

What I’ve done so far

I was going to put screenshots too, but I have a max 3 images per post as a new user… Let me know if you want to see them.

  1. Determine whether this is a new or returning user and direct them to the correct place. This isn’t how I wanted to do it, but I guess it works…

  2. Create a new record for a PT

  3. Create a new record for the Client, which saves under PT name which they provide, but it will create a new PT

Where I am stuck/What I’ve tried

I simply don’t understand how to query the realtimeDB for a match on the user’s details, and I can’t find any articles about running a query on realtimeDB.

Does anyone have any suggestions?

Hey @jamesx - this sounds like a great idea for an app. Have you made much progress with it?

It sounds like this could be one area where errors might occur. Have you considered using a ListViewer to show a set list of personal trainers?