I'm trying to fetch a document from my firebase using AngularFire2. My goal is to fetch the document and then based on that ID send another request to fetch a sub-collection on that very same document.
I tried using switchMap but it didn't do the trick, how can I do that? This is my implementation for the first call, where I get document.
getUsers(start?: number): Observable<BasicUser[] | any> {
const q = this.af.collection(this.COLLECTION_PATH, ref =>
ref.limit(25)
.orderBy('creationDate')
.startAt(start || 0))
.snapshotChanges()
.pipe(
map(snaps => {
return snaps.map(snap => {
const data: any = snap.payload.doc.data();
return {
id: snap.payload.doc.id,
firstName: data.firstName,
lastName: data.lastName,
creationDate: data.creationDate
} as unknown as BasicUser;
})
})
);
return q;
}
Inside that document has a sub-collection called private
, I need to fetch that data.