【问题标题】:How to retrieve documents form firebase firestore according to a specific value in those documents in flutter?如何根据颤动中那些文档中的特定值从firebase firestore检索文档?
【发布时间】:2021-11-11 16:41:12
【问题描述】:

我在 Firestore 上有以下结构, 我想检索具有相同类别或类型的系列文档(一次 10 个文档)。

EX: 10 series documents of category Mystery

我知道这是使用where()limit() 方法完成的,但我不知道如何访问categories array 中的对象,尤其是当它们没有名称时。

【问题讨论】:

    标签: firebase flutter google-cloud-firestore


    【解决方案1】:

    目前,您无法在嵌套列表中搜索嵌套项,但是您可以在列表中搜索确切的对象,在您的情况下,它是 Map<String, String>

    所以,使用这个,它可能\应该工作:

    .where('categories', arrayContains: {"ar_title": غموض, "en_title":"Mystery"})
    

    【讨论】:

    • 它必须是确切的对象吗?我的意思是我不能只传递“en_title”吗??
    • 不幸的是,不是,因为从 Firebase 的角度来看。它有一个类别列表,在每个索引处,里面都有en_title。数组仅包含在第一级类别中的外观,在 index0、index1..etc 但您真正需要的是它查看每个索引内部,如果它包含en_title,然后是@987654325 @ 匹配 Mystery。目前,他们不这样做。
    猜你喜欢
    • 2020-11-08
    • 2020-08-05
    • 2021-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-14
    • 2021-10-09
    • 2013-03-19
    相关资源
    最近更新 更多