我正在尝试允许用户访问其userID文档及其子集合或文档
在路径: / main-collection / {userid}
并且我希望“ admin-userid”具有对所有/ main-collection文档和子集合的读取权限
/ main-collection / {userid}作为文档
service cloud.firestore {
match /databases/{database}/documents {
match /main-collection/{userId} {
allow read, write: if request.auth.uid == userId || request.auth.uid == 'admin-userid';
match /{document=**} {
allow read, write: if request.auth.uid == userId || request.auth.uid == 'admin-userid';
}
}
}
}
答案 0 :(得分:0)
如果用户和管理员用户需要对集合和文档的子集合中的所有内容具有相同的权限:
match /main-collection/{userId} {
allow read, write: if request.auth.uid == userId || request.auth.uid == 'admin-userid';
}
match /main-collection/{userId}/{document=**} {
allow read, write: if request.auth.uid == userId || request.auth.uid == 'admin-userid';
}