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

246
Visualizações
Get the ID of firebase document

so I have this collection:

//console.log(currentUserUID)


   await fire
       .firestore()
       .collection('userEventsCal')
       .doc(currentUserUID)
       .collection(eventID)
       .get()

I am calling this in a new page, so I don't have access to the eventID. I am trying to figure out how to do it with just

await fire
           .firestore()
           .collection('userEventsCal')
           .doc(currentUserUID)

but it's failing. Is my logic wrong or is this just impossible to do?

 await fire
       .firestore()
       .collection('userEventsCal')
       .doc(currentUserUID)
       .get().then((doc) => {
        if (doc.exists) {
            console.log("Doc data lol:", doc.data());
        } else {
            // doc.data() will be undefined in this case
            console.log("No such document!");
        }
    }).catch((error) => {
        console.log("Error getting document:", error);
    });

It looks like this in firebase:

enter image description here

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I understand that you want to list the subcollections of the document with the DocumentReference corresponding to firestore().collection('userEventsCal').doc(currentUserUID).

As a matter of fact, retrieving a list of collections is not possible with the mobile/web client libraries, as explained in the Firestore documentation.

I wrote an article which proposes solutions to this problem: How to list all subcollections of a Cloud Firestore document?.

Basically, you can either save the list in a dedicated field of the parent document or use a Cloud Function.

At first glance it seems the first approach is probably the most interesting one in your case. Note however the 1MB limit for a document.

about 4 years ago · Juan Pablo Isaza Relatório
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