Google cloud firestore Firestore集合组安全规则的匹配路径中的文档段是否必须使用通配符? db.collectionGroup('private')) .where('members','array contains',userId) .get() .然后(…)
如果相关的安全规则设置为:Google cloud firestore Firestore集合组安全规则的匹配路径中的文档段是否必须使用通配符? db.collectionGroup('private')) .where('members','array contains',userId) .get() .然后(…),google-cloud-firestore,firebase-security,Google Cloud Firestore,Firebase Security,如果相关的安全规则设置为: match /{path=**}/private/{document} { allow read: if request.auth.uid in resource.data.members; } 但是,下面的类似规则阻止意外执行相同的查询 match /{path=**}/private/allowed { allow read: if request.auth.uid in resource.data.members; } 在这个数据库中 privat
match /{path=**}/private/{document} {
allow read: if request.auth.uid in resource.data.members;
}
但是,下面的类似规则阻止意外执行相同的查询
match /{path=**}/private/allowed {
allow read: if request.auth.uid in resource.data.members;
}
在这个数据库中
子集合仅存在于private
集合中的文档下rooms
- 每个
只有一个ID为“allowed”的文档private
/rooms/xxxxxxxx/private/allowed
是唯一可能存在的路径,其中xxxxxxxx
是自动分配的文档ID。
因此,在我看来,将路径指定为/{path=**}/private/allowed
是正确的
事实上,“get”查询在操场上的模拟中起作用,所以它只是对集合组查询的限制,还是我做错了什么
仅供参考,我的另一个问题中描述了更详细的数据库结构。是的,它是必需的
执行集合组查询时,无法在查询中调出特定的文档id(例如“允许”)。该查询明确要求在给定的名称(“私有”)的子集合的<强>所有< /强>中考虑<强> >所有< /强>。因此,规则必须允许通过添加尾随通配符来考虑这些文档
如果只想获取具有特定字段值的特定文档,当然可以向查询中添加筛选器,但该筛选器不能在规则中强制执行