firebase - Firestore查询无法获取文档

标签 firebase flutter dart google-cloud-firestore

所以我在一个名为“作者”的集合中有一个数组。我想检查某个字符串(邮件)是否存在,但是它说对getDocuments的权限被拒绝。
这是一个小片段:

  List<String> authors;

  _getAuthors(DocumentSnapshot doc) async {
    if (await FirebaseAuth.instance.currentUser() != null) {
      var query = Firestore.instance
          .collection('mealList')
          .where('Authors', arrayContains: mail);
      query.getDocuments().then((value) => print(value));
    }
  }

  Widget buildItem(DocumentSnapshot doc) {
    DateTime now = doc.data['Date'].toDate();
    DateFormat formatter = DateFormat('dd-MM-yyyy');
    String formatted = formatter.format(now);
    _getUserId();
    _getMail(doc);
    if (doc.data['Authors'] != null) {
      _getAuthors(doc);
    }

这是我的数据库规则:
rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {

    match /mealList/{uid} {
      allow read, write: if request.auth == null;
    }

    match /shoppingList/{uid} {
      allow read, write: if request.auth != null;
    }
  }
}

最佳答案

   match /mealList/{uid} {
      allow read, write: if request.auth == null;
    }

should be 

   match /mealList/{uid} {
      allow read, write: if request.auth != null;
    }

关于firebase - Firestore查询无法获取文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62012072/

相关文章:

android - 无法解析类扩展 BaseAdapter 中的方法 'getBaseContext()'

flutter - 如何在 flutter 中的文本字段中填充数据

list - Flutter FireStore空列表

firebase - 使用其他网站的凭据创建 Firebase 身份验证

function - Iterable.expand(Iterable Function(dynamic) f) 函数在 Dart 中如何工作?

python - 通过使用 Python 给出属于该文档的字段值来获取 firestore 中文档的数据?

firebase - 需要启用 App Engine 才能使用 Cloud Firestore

swift - 'AuthDataResult' 没有成员 uid 错误

android - 加速度计在运行几分钟后同时触发多次

firebase - 错误 : Cloud not find the correct Provider<List<Brew>> above this BrewList Widget