最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

无法使用Firestore中的规则访问文档内部的集合

网站源码admin15浏览0评论

无法使用Firestore中的规则访问文档内部的集合

无法使用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.的更多信息
发布评论

评论列表(0)

  1. 暂无评论