How to populate reference data type in firebase react?

Viewed 22

I am working on my project. I have some documents in collection in firebase firestore database. Each document contains an email field. I want to populate email field when i call getDocs function for getting all documents in collection.

enter image description here

My Code to get all documents

// Create a query against the collection and fetch the documents where "status" == "published"
    const allBlogs = query(
      blogsRef,
      where("status", "==", "Published"),
      orderBy("views", "desc")
    );
    // executing query
    const allBlogsSnapshot = await getDocs(allBlogs);

    // doc.data() is never undefined for query doc snapshots
    setBlogs(
      allBlogsSnapshot.docs.map((doc) => ({
        ...doc.data(),
        id: doc.id,
      }))
    );
0 Answers
Related