Firestore查询无法获取文档

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/

10-09 04:39