firebase - 我们如何限制从 Firebase 获得的快照数量?
问题描述
我正在开发一个 Flutter 消息传递应用程序,我在其中使用 Friebase 作为数据库。每次加载消息时,它都会一次加载所有消息。我希望它一次只加载 x 个数据。我尝试使用限制,但没有帮助。
body: new Column(children: <Widget>[
new StreamBuilder<QuerySnapshot>(
stream: Firestore.instance
.collection('messages')
.where("threadId", isEqualTo: thread.id)
.limit(10)
.snapshots,
解决方案
我用过.limit(number)
,效果很好。也许你应该检查你的 where 条件。顺便说一句,你的语法.snapshots
不正确,它必须是.snapshots()
推荐阅读
- splunk - Splunk:从 JSON 结构中提取元素作为单独的字段
- python - 来自 Python 的 Shell 命令“env:节点:没有这样的文件或目录”
- three.js - 使用 three.js 在 Mapbox GL JS 层上渲染多个 3-D 对象
- javascript - 使用 JavaScript 发送的电子邮件未发送
- selenium - 如何在 Firefox-Selenium 中添加“From”请求标头?
- c++ - 无法理解 C/Linux 中信号函数的声明
- sqlite - 如何在 SQLite WAL 和 SHM 文件上设置全局可写权限?
- mysql - 将 Excel 公式转换为 SQL 查询
- javascript - jsdom如何在foreach中的另一个元素中获取一个元素
- python - AsyncIO 和 concurrent.futures.ThreadPoolExecutor