首页 > 解决方案 > 使用 Flutter 在一次往返中从 firestore 获取 10 多个文档

问题描述

我目前正在whereIn为此使用。但一次只能获得 10 个或更少的文件。根据 Firestore 文档,其中 10 个或更少的条目

有什么方法可以在一次往返中一次获取 10 多个文件?

 return _db
        .collection('books')
        .where('docId', whereIn: ['id1', 'id2'...'id10'])
        .get()
        .then((value) => value.docs.map((e) => BookModel.fromFireStore(e)).toList());

标签: firebasefluttergoogle-cloud-firestore

解决方案


不,10 是硬限制,不能超过。您将需要执行多个查询才能按 ID 获取超过 10 个文档。该文档指出:

使用in运算符将​​同一字段上的最多 10 个相等 (==) 子句与逻辑 OR 组合在一起。


推荐阅读