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

216
Views
WEBPACK_IMPORTED_MODULE_3 CollectionGroup is not a function - firebase collection group querying nested data

Prompt: There are 5 products. Each product has 5 video reviews. These reviews are nested in the following data structure.

products > docs > productReviewClips > docs {videoUrl: https://videoclip.mp4, uid: 1234}.

Each productReviewClips doc has a videoUrl.

Am I querying the videoUrls from all the products the wrong way?

const [feed, setFeed] = useState([]);

useEffect(() => { 
        firestore.collection('products').doc().collectionGroup('productReviewClips')
        .onSnapshot((snapshot) => {
            // console.log(JSON.stringify(snapshot) + "1")

            setFeed([...snapshot.docs.map((doc) => {
                return {
                    ...doc.data(),
                    documentID: doc.id,
                };
            })
        ])

        })
        },
   [])
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

When you call doc() without arguments, it generates a new unique ID. For a collection group query, skip the initial collection('products').doc() altogether and do:

firestore.collectionGroup('productReviewClips')...

The collectionGroup function is a part of the Firestore object, it's not available on a CollectionReference or DocumentReference object which is also why you get the "not a function" error.

If you want to search only productReviewClips collections under a specific path, that is possible with a trick Sam explains here: CollectionGroupQuery but limit search to subcollections under a particular 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!