【问题标题】:Flutter Firebase get documents by array of IDsFlutter Firebase 通过 ID 数组获取文档
【发布时间】:2020-03-24 02:26:56
【问题描述】:

如何使用 ID 列表从集合中获取文档查询?假设我有以下内容:

List<String> someList = ['abc123', 'def456', 'hij789']; // Need to query for these documentIDs

我通常会执行以下操作。但这显然行不通,因为我需要查询 documentID。

Query query = Firestore.instance
        .collection(APIPath.products())
        .where('someField', whereIn: someList);

【问题讨论】:

    标签: firebase flutter google-cloud-firestore


    【解决方案1】:

    尝试使用FieldPath.documentId()

    Query query = Firestore.instance
            .collection(APIPath.products())
            .where(FieldPath.documentId(), whereIn: someList);
    

    请注意,列表中限制为 10 项,这实际上可能比使用 get() 单独请求每个文档要慢。

    【讨论】:

    • 非常感谢!只是想知道如何将 get() 用于多个查询并返回一个流。限制10有点令人担忧。
    • 我不知道 - 我建议提出一个新问题。
    猜你喜欢
    • 2021-05-06
    • 2021-11-19
    • 2020-11-02
    • 2021-01-28
    • 2019-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-20
    相关资源
    最近更新 更多