【发布时间】:2019-09-18 06:16:02
【问题描述】:
我目前有一个类似于 this 的 Firestore:
Collection('machines').doc(*machineID*).collection('reports').doc(*multiple docs reports*)
我正在使用Vue,我正在尝试获取“报告”集合中的所有文档。
我可以获得一份报告:
reports: firebase.firestore()
.collection('machine')
.doc('machine_01')
.collection('report')
.doc('report_05')
但我无法获得整个子集合
reports: firebase.firestore()
.collection('machine')
.doc('machine_01')
.collection('report')
这可能吗?我是新手,所以这可能是一个愚蠢的问题。
谢谢!
编辑 我在控制台中收到的错误消息是:
index.cjs.js?e89a:350 Uncaught (in promise) FirebaseError: Missing or insufficient permissions.
at new FirestoreError (webpack-internal:///./node_modules/@firebase/firestore/dist/index.cjs.js:350:28)
at JsonProtoSerializer.fromRpcStatus (webpack-internal:///./node_modules/@firebase/firestore/dist/index.cjs.js:14844:16)
at JsonProtoSerializer.fromWatchChange (webpack-internal:///./node_modules/@firebase/firestore/dist/index.cjs.js:15335:44)
at PersistentListenStream.onMessage (webpack-internal:///./node_modules/@firebase/firestore/dist/index.cjs.js:11305:43)
at eval (webpack-internal:///./node_modules/@firebase/firestore/dist/index.cjs.js:11234:30)
at eval (webpack-internal:///./node_modules/@firebase/firestore/dist/index.cjs.js:11274:28)
at eval (webpack-internal:///./node_modules/@firebase/firestore/dist/index.cjs.js:1634:20)
我不确定权限,我无权访问它们,但如果是权限问题,我很困惑我可以从集合中获取单个文档,但找不到方法获取所有文件
【问题讨论】:
-
Missing or insufficient permissions错误表示您没有读取数据的权限。您需要允许用户访问您的数据库的 Firebase 安全规则中的数据。 -
看一下文档:firebase.google.com/docs/firestore/security/rules-structure: "A read rule can be broken into get and list"。
标签: javascript firebase google-cloud-firestore