规则访问文档内部的集合"/>
无法使用Firestore中的规则访问文档内部的集合
我正在尝试在我的应用程序中将像这样的集合中的一组文档收集起来:
const plans = await firebase.firestore()
.collection('users')
.doc(userId)
.collection('plans')
.get();
我的Firestore规则设置如下:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow create: if request.auth.uid != null;
allow get: if request.auth.uid == userId;
match /plans/{document=**} {
allow create, get, update, delete: if request.auth.uid == userId;
}
}
}
}
每次尝试查询计划集合中的所有文档,都会收到此错误
FirebaseError: Missing or insufficient permissions
但是,如果我尝试仅查询用户文档
firebase.firestore().collection('users').doc(userId).get()
效果很好。我已经坚持了一段时间。我想念什么吗?
回答如下:阅读有关granular operations in the documentation.的更多信息更多推荐
无法使用Firestore中的规则访问文档内部的集合
发布评论