Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

587
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda