I’ve asked this on stackoverflow, I feel like it’s relevant here as well.
I’m passing an array of Province Ids provinceIds and I wanna query and return all Universities within each Province . So far I’m only returning universities from the first Province. There are exactly 9 possible Ids that can be passed (9 South African provinces). I tried iterating, and I just ended with a lot of weird code that ‘I’ didn’t understand myself.
If you know any other way to do this, I’m open.
export class UniversitiesService {
private collection: AngularFirestoreCollection<University>;
universities: Observable<University[]>;
constructor(
private afs: AngularFirestore
) { }
getUniversitiesByProvince(provinceIds: string[]): Observable<University[]> {
this.collection = this.afs.collection('Universities',
ref => ref.where('provinceID', '==', provinceIds[0]));
this.universities = this.collection.snapshotChanges()
.map(actions => {
return actions.map(a => {
const data = a.payload.doc.data() as University;
data.Id = a.payload.doc.id;
return data;
});
});
return this.universities;
}
}
