我目前有一个类似 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)
我不确定权限,我没有访问权限,但是如果是权限问题,我很困惑,我只能从集合中获取单个文档,但是找不到方法获取所有文件
答案 0 :(得分:0)
由于出现Missing or insufficient permissions
错误。看起来用户无权访问您的数据库信息;因此,我将尝试执行以下操作:
// Allow read/write access on all documents to any user signed in to the application
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth.uid != null;
}
}
}
更多信息 here