1

我一直在尝试使用以下安全规则使子集合中的所有文档完全可读:

 match /books {
     allow write, update, delete: if false; // This collection cannot be modified
  
     match /sells {
         allow read: if true; // All documents and sub-collections of this collection are readable
     }
 }

但是,当我尝试阅读出售子集合的文档时,我收到 Firebase 权限错误。我究竟做错了什么?

4

1 回答 1

3

您需要匹配集合中的文档

 match /sells/{doc} {
     allow read: if true; // All documents in sells are readable
 }

如果您还想匹配sells文档的子集合,可以使用递归通配符,如下所示:

 match /sells/{doc=**} {
     allow read: if true; // All documents in and sub-collections of sells are readable
 }
于 2020-10-31T04:17:00.687 回答