3
votes

The firestore .collectionGroup() method is getting an error when using it with the firebase-admin sdk in a cloud function. Is it possible to make a collection group query to firestore in a cloud function?

Here is the firestore query method I'm trying to use: https://googleapis.dev/nodejs/firestore/latest/Firestore.html#collectionGroup

But it doesn't seem to be available in the firestore admin SDK: https://firebase.google.com/docs/reference/admin/node/admin.firestore

admin.firestore().collectionGroup('photos').where('id', '==', photoId);

I get this error when running the function:

TypeError: admin.firestore(...).collectionGroup is not a function

Wondering if I'm missing something, or if this something that will be added in the future.

1

1 Answers

3
votes

This typically means you're using a version of the Admin SDK that doesn't support Collection Group Queries yet.

Support for Collection Group Queries was introduced in version 7.4.0, based on Cloud Firestore client 1.3.0. Check your package.json to ensure you're using these versions or newer.