首页 > 解决方案 > 如何从firestore中的字符串数组中查找字符串

问题描述

我有一个文档列表,每个文档都有一个名为“fav”的字符串数组字段,它有超过 50k 封电子邮件,几乎有 1000 个文档,每个文档的“fav”数组的长度可变,包括 50k、20k、10等。我正在获取所有文件

 Firestore.instance.collection("save").snapshots();

通过 StreamBuilder

StreamBuilder(
      stream: Firestore.instance.collection("save").snapshots();,
      builder: (context, snapshot) {
        if (!snapshot.hasData)
          return Text("Loading Data.............");
        else {
          listdata = snapshot.data.documents;

          return _buildBody(snapshot.data.documents);
        }
      },
    )

现在我如何从每个文档的“fav”字段中搜索我所需的电子邮件?我必须在本地找到数组中所需的 id 后执行操作。

场地

标签: stringfirebasefluttergoogle-cloud-firestoregoogle-cloud-functions

解决方案


这个问题不是很清楚,但据我了解,这就是你要找的

Firestore.instance.collection('save')
.where('fav', arrayContains: 'abc@gmail.com').snapshots()

推荐阅读