Firebase 函数:类型错误:collectionRef.count 不是函数

Tha*_*hật 5 node.js firebase google-cloud-firestore

我在遵循此处使用 count() 聚合的示例时遇到错误

我的代码是:

const collectionRef = db.collection('cities');
const snapshot = await collectionRef.count().get();
const amount = snapshot.data().count;
res.json({ amount });
Run Code Online (Sandbox Code Playgroud)

错误说:

函数:类型错误:collectionRef.count不是函数

有人可以帮忙吗?

Dha*_*raj 6

count()查询已添加到firebase-admin@11.2.0. 如果您使用的是旧版本,请尝试更新到最新版本。

npm i firebase-admin@latest
Run Code Online (Sandbox Code Playgroud)

  • 你是我的救星。非常感谢你。:) (2认同)