[英]How to get specific Documents of a Subcollection of all Documents in a Collection in Firestore?
[英]How to get all documents in a firestore subcollection
我目前有一个看起来像这样的消防站:
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
错误。 看起来用户无权访问您的数据库信息; 因此,我将尝试执行以下操作:
// 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;
}
}
}
更多信息在这里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.