我為我的 Firestore 數(shù)據(jù)庫設置了以下規(guī)則:rules_version = '2';service cloud.firestore { match /databases/{database}/documents { match /collections/{document=**} { allow read; allow write: if isAdmin(); } match /general/{document=**} { allow read; allow write: if isAdmin(); } match /inquiries/{document=**} { allow write; allow read: if isAdmin(); } match /orders/{document=**} { allow write; allow read: if isAdmin() || resource.data.userID == request.auth.uid; } match /products/{document=**} { allow read; allow write: if isAdmin(); } match /users/{userId} { allow write, read: if belongsTo(userId); } function belongsTo(userId) { return request.auth.uid == userId } function isAdmin() { return resource.data.admin == true; } }}如您所見,每個人都可以閱讀 /products 及其文檔以及子集合。哪個適用于產(chǎn)品,但不知何故無法讀取產(chǎn)品的子集合(每個產(chǎn)品都有一個名為)。collection-colorsFirebaseError:權(quán)限缺失或不足。導致錯誤的代碼:retrieveCollectionColors(name) { this.db.collectionGroup('collection-colors', ref => ref.where('product', '==', name)) .valueChanges().subscribe( (val: []) => { this.collectionColors.next(val); }, error => { console.log(error); });}
Firestore返回的權(quán)限不足,即使它不應該
慕妹3146593
2022-01-13 16:51:34