I am struggling to extract specific teams from a group of teams. It appears that I need to transform the snapshot into the Team object. Is there a simpler way to convert a snapshot into an array? As a beginner in firebase/angular, I may be overlooking something basic.
using angular 5.5.2
export class Team {
internalTeamName: string;
externalTeamName: string;
creatorNumber: number;
teamAdmins: TeamMember[];
teamMembers: TeamMember[];
constructor(code ommitted)
}
service.module
loadTeams(email){
const teamArray: Team[] = null;
this.firestore.collection('teams', ref => ref.where('teamAdmins', 'array-contains', email))
.get()
.forEach(function(childSnapshot) {
teamArray.push(childSnapshot);})
.then(
return teamArray )
.catch(
err => console.log(err)
)
The error message generated by the code above: Argument of type 'QuerySnapshot' is not assignable to parameter of type 'Team'. Type 'QuerySnapshot' is missing the following properties from type 'Team': internalTeamName, externalTeamName, creatorNumber, teamAdmins, teamMembers
function calling the above function: What is the best practice when calling service functions?
public teamArray: Team[] = null;
ngOnInit() {
this.teamArray = this.teamCrudService.loadTeams(this.authService.email);
}