javascript - 为什么 ref.getCollections() 不被识别为函数?

标签 javascript node.js reactjs firebase

我正在做一个将用户数据存储在 Cloud firestore 上的网站。我用它一次获取用户文档的所有子集合:

db.collection('users').doc(userID).getCollections().then( collections => {
  /*I get my collections and I enjoy it :D*/
})

问题是这个函数没有被识别。我在控制台上发现这条消息:

TypeError: db.collection(...).doc(...).getCollections is not a function

我知道否则我可以获得所有子集合,但由于配额有限,我想保存最多的读数。所有其他 firebase 函数都在我的项目中工作(如 get()set())并且 getCollections() 在文档中。 感谢您的帮助!

最佳答案

Google 团队已将方法名称从“getCollections”替换为“listCollections”。所以你应该再次更新这个方法名称。 引用这里https://googleapis.dev/nodejs/firestore/latest/DocumentReference.html#listCollections

它适用于以下工具版本:firebase-tools v7.2.1、firebase-admin v8.3.0、firebase-functions v3.2.0。

关于javascript - 为什么 ref.getCollections() 不被识别为函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56509531/

相关文章:

javascript - node.js 应用程序中 "Cannot read property ' replace' of undefined"的原因是什么

reactjs - 使用 Remix 嵌入 GitHub Gist

javascript - Handlebars 助手的 Ember View 无法检测到自己何时被单击

javascript - 当用户离开页面时在 angularjs 中显示自定义确认框

javascript - 使用 window.onbeforeunload 时捕获用户响应

javascript - 在 Socket IO 和 Node JS 中轮询 MySQL DB

javascript - 我在类里面使用 promise 哪里出错了?

javascript - 分派(dispatch) redux 操作时 JS 执行乱序

javascript - React 只理解随机键?

javascript - 为什么在填写所有字段之前我的提交按钮会重新启用?