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

236
Views
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 answers
Answer question

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 Report
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!