Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

584
Views
How to fetch document and sub-document on Firebase

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!