Flutter Firebase按ID数组获取文档 [英] Flutter Firebase get documents by array of IDs

查看:52
本文介绍了Flutter Firebase按ID数组获取文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How would I get a Query of documents from a collection using a list of IDs? Let's says I have the following:

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

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

I would normally do the following. But this obviously won't work since I need to query the documentIDs.

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

推荐答案

尝试使用请注意,列表中最多只能包含10个项目,这实际上可能比仅通过 get()单独请求每个文档要慢.

Note that you are limited to 10 items in the list, and this might actually be slower than just requesting each document individually with get().

这篇关于Flutter Firebase按ID数组获取文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆