I need help to draw my firestore schema. Root collection User - ID1 (athlete) ID2 (coach) -> subColl (Page) ID3
The user can be a trainer or an athlete
If it is trainer it saves the public data in another root collection called
trainerInfo - ID (same as trainer ID example ID2)
Through trainerInfo the athlete can see the list of available trainers With function:
fetchAvailableTrainer (): Observable <PublicTrainerInfo []> {
return from (
this.afs
.collection <PublicTrainerInfo> (`trainerInfo`)
.valueChanges ({idField: 'idField'})
);
}
When the trainer selects a trainer he can see his page which is a sub-collection of users with the function:
fetchTrainerPageFromAthlete (id): Observable <TrainerPage> {
const collection = this.afs.collection <TrainerPage> (
`users / $ {id} / trainerPage`
);
const trainerPage $ = collection.valueChanges ({idField: 'idField'}). pipe (
map ((trainerPage) => {
const trainerPage2 = trainerPage [0];
return trainerPage2;
})
);
returns trainerPage $;
}
I wonder is it okay to expose the trainer ID?
You need not hide user ID. To restrict other users accessing the user data, you have to set firebase rule. This document will help you.