Firebase 如何授予用户访问集合的所有子文档和子集合的权限

Firebase 如何授予用户访问集合的所有子文档和子集合的权限,firebase,google-cloud-firestore,firebase-security,Firebase,Google Cloud Firestore,Firebase Security,我想知道您如何授予用户访问Firebase Firestore中收藏的所有子收藏和文档的权限。 例子: 如果我的规则文件中有以下代码 match /databases/{database}/documents { match /LogInCodes/{codes} { allow read: if true allow write: if false } } ,用户可以阅读/LogInCodes/firstDocument,但不能阅读/L

我想知道您如何授予用户访问Firebase Firestore中收藏的所有子收藏和文档的权限。 例子: 如果我的规则文件中有以下代码

  match /databases/{database}/documents {
        match /LogInCodes/{codes} {
        allow read: if true
      allow write: if false
    }
}
,用户可以阅读
/LogInCodes/firstDocument
,但不能阅读
/LogInCodes/firstDocument/subfolder/subdocument
。我如何授予用户访问以下所有子集合和文档的权限

希望你能理解我。
谢谢,Boothosh

您可以访问特定的子集合:

match/databases/{database}/documents{
匹配/LogInCodes/{code}{
允许读取:如果为真
允许写入:如果为false
//显式定义“subcollextion1”子集合的规则
匹配/子集合1/{landmark}{
允许读、写:如果;
}
}
}
或所有子集合:

match/databases/{database}/documents{
匹配/LogInCodes/{code}{
允许读取:如果为真
允许写入:如果为false
//匹配任何子集合中的任何文档。
匹配/{document=**}{
允许读、写:如果;
}
}
}
你可以阅读更多关于它的内容


还要注意您使用的安全规则的版本。两者略有不同。但您可以自己定义要使用的版本。

您可以授予对特定子集合的访问权限:

match/databases/{database}/documents{
匹配/LogInCodes/{code}{
允许读取:如果为真
允许写入:如果为false
//显式定义“subcollextion1”子集合的规则
匹配/子集合1/{landmark}{
允许读、写:如果;
}
}
}
或所有子集合:

match/databases/{database}/documents{
匹配/LogInCodes/{code}{
允许读取:如果为真
允许写入:如果为false
//匹配任何子集合中的任何文档。
匹配/{document=**}{
允许读、写:如果;
}
}
}
你可以阅读更多关于它的内容

还要注意您使用的安全规则的版本。两者略有不同。但您可以自己定义要使用的版本