node.js - Firebase 函数 : TypeError: collectionRef. 计数不是函数

标签 node.js firebase google-cloud-firestore

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

我的代码是:

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

错误说:

Functions: TypeError: collectionRef.count is not a function

有人可以帮忙吗?

最佳答案

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

npm i firebase-admin@latest

关于node.js - Firebase 函数 : TypeError: collectionRef. 计数不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74508056/

相关文章:

node.js - 预编译 Handlebars 模板

javascript - 如何确定 JEST 是否正在运行代码?

node.js - 为什么 Eventarc 触发器在 Firebase 中不起作用?

javascript - Firebase 在登录时将对象返回到本地存储,但如何访问它?

firebase - Google Cloud Firestore 订单字符串字段,如数字

ios - 按社交网络 iOS 应用程序中的相互连接与 firestore 中的数据存储进行排序

c++ - Node JS - 模块没有自行注册

node.js - Visual Studio Team Services Azure 部署(无法对指定目录执行操作 ("Delete File")

flutter - 如何从ListView获取值列表

node.js - 使用 node.js 的用户输入