Javascript 如何获取firestore子集合中的所有文档
我目前有一个firestore,看起来像这个:Javascript 如何获取firestore子集合中的所有文档,javascript,firebase,google-cloud-firestore,Javascript,Firebase,Google Cloud Firestore,我目前有一个firestore,看起来像这个: Collection('machines').doc(*machineID*).collection('reports').doc(*multiple docs reports*) reports: firebase.firestore() .collection('machine') .doc('machine_01') .collection('report') .doc('report_05') 我正在使用Vue,并试图获
Collection('machines').doc(*machineID*).collection('reports').doc(*multiple docs reports*)
reports: firebase.firestore()
.collection('machine')
.doc('machine_01')
.collection('report')
.doc('report_05')
我正在使用Vue
,并试图获取“报告”集合中的所有文档
我可以得到一份报告:
Collection('machines').doc(*machineID*).collection('reports').doc(*multiple docs reports*)
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)
我不确定权限,我没有访问权限,但如果是权限问题,我很困惑我可以从集合中获取一个文档,但找不到获取所有文档的方法,因为您遇到了
权限缺失或不足的错误。用户似乎无权访问您的数据库信息;因此,我将努力做到以下几点:
// 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;
}
}
}
更多信息权限缺失或不足错误意味着您没有读取数据的权限。您需要允许用户访问数据库的Firebase安全规则中的数据。请查看文档::“读取规则可以分为get和list”。