使用admin SDK在云端功能中执行Firestore集合组查询? [英] Perform firestore collection group query in cloud functions with admin sdk?
问题描述
firestore .collectionGroup()方法在云功能中与firebase-admin sdk一起使用时出现错误.是否可以将集合组查询发送到云功能中的Firestore?
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?
这是我要使用的Firestore查询方法: https://googleapis.dev/nodejs/firestore/latest/Firestore.html#collectionGroup
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不是函数
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.
推荐答案
这通常意味着您使用的是尚不支持集合组查询的Admin SDK版本.
This typically means you're using a version of the Admin SDK that doesn't support Collection Group Queries yet.
在版本7.4中引入了对集合组查询的支持.0 ,基于Cloud Firestore客户端1.3.0.检查您的package.json以确保您使用的是这些版本或更高版本.
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.
这篇关于使用admin SDK在云端功能中执行Firestore集合组查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!