为什么ref.getCollections()无法识别为函数?

时间:2019-06-08 19:31:51

标签: 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()在文档中。 谢谢您的帮助!

2 个答案:

答案 0 :(得分:0)

在您的示例中,db.collection('users')。doc(userID)返回DocumentReference 到目前为止,我可以看到DocumentReference对象不支持getCollections方法

这里是文档https://firebase.google.com/docs/reference/js/firebase.firestore.DocumentReference

答案 1 :(得分:0)

Google小组的名称从“ getCollections”更改为“ listCollections”。因此,您应该再次更新此方法名称。 参考此处https://googleapis.dev/nodejs/firestore/latest/DocumentReference.html#listCollections

相关问题