I have an angular 8 typescript interface set up that contains an array of another interface as a variable. Here is the structure:
export interface User {
name: string;
id: string;
history: Job[]; //this part isn't getting populated
}
The Job interface is defined as follows:
export interface JobJson {
id: string;
price: number,
notes: string
}
My database setup involves using Firebase's Cloud Firestore and has the following structure:
users // collection
|--> user1234 // document
|--> jobs //subcollection
|--> job1234 // sub document
When I retrieve a user from firebase using a query:
this.firestore.collection<UserJson>('users').doc<UserJson>(id).valueChanges().subscribe((u) => {
// work with u data here
});
As anticipated, the history field in user object remains empty. However, it is essential for my program to populate the user.history array with the subcollection data under user in Firebase. Is there a way to achieve this? Any assistance would be appreciated!