Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

585
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda