返回空结果的Firebase搜索查询

返回空结果的Firebase搜索查询,firebase,flutter,dart,collections,google-cloud-firestore,Firebase,Flutter,Dart,Collections,Google Cloud Firestore,我想看看“chefCollection”中的任何文档中是否存在“chefId”(屏幕截图的包围字段)。为此,我在下面写下我的疑问 Future<bool> checkChefID(String userID) async { final chefCheck = (await Firestore.instance.collection('chef') .document("chefId") .collecti

我想看看“chefCollection”中的任何文档中是否存在“chefId”(屏幕截图的包围字段)。为此,我在下面写下我的疑问

Future<bool> checkChefID(String userID) async {
    
final chefCheck = (await Firestore.instance.collection('chef')
            .document("chefId")
            .collection("chef")
            .where("chefID", isEqualTo: userID)
            .getDocuments())
        .documents;

    print("Query result:  " + chefCheck.toString());
    chefCheck.length > 0 ? return true : return false;

  }
更改此项:

final chefCheck = (await Firestore.instance.collection('chef')
            .document("chefId")
            .collection("chef")
            .where("chefID", isEqualTo: userID)
            .getDocuments())
        .documents;
为此:

final chefCheck = (await Firestore.instance.collection('chef')
            .where("chefID", isEqualTo: userID)
            .getDocuments())
        .documents;

在数据库中,您有一个名为
chef
的集合,文档中有一个名为
chefID
的字段,因此您不应该有
.document(“chefID”).collection(“chef”)

Oops。我的错。谢谢彼得:)你能告诉我我应该写什么查询来提取某个集合文档的所有字段以及键和值吗?我是Firebase查询新手。我正在努力做到这一点。@FaizanKamal请将它作为另一个问题提问,并附上您使用的解释和代码,链接到这里,以便我可以检查它