我想知道如何授予用户访问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 {
match /LogInCodes/{codes} {
allow read: if true
allow write: if false
// Explicitly define rules for the 'subcollextion1' subcollection
match /subcollextion1/{landmark} {
allow read, write: if <condition>;
}
}
}
或所有子集合:
match /databases/{database}/documents {
match /LogInCodes/{codes} {
allow read: if true
allow write: if false
// Matches any document in any subcollection.
match /{document=**} {
allow read, write: if <condition>;
}
}
}
你可以在这里阅读更多关于它的信息。
还要注意你使用的安全规则的版本。两者略有不同。但是您可以自己定义要使用的版本。