Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perform firestore collection group query in cloud functions with admin sdk?

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.

like image 808
Dan Broadbent Avatar asked Aug 31 '25 01:08

Dan Broadbent


1 Answers

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.

like image 161
Frank van Puffelen Avatar answered Sep 02 '25 15:09

Frank van Puffelen