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

编程入门 行业动态 更新时间:2024-10-07 22:29:24

无法使用Firestore中的<a href=https://www.elefans.com/category/jswz/34/1771204.html style=规则访问文档内部的集合"/>

无法使用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中的规则访问文档内部的集合

本文发布于:2024-05-07 10:30:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1755839.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:规则   文档   Firestore

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!