使用 startAfter 进行 Flutter Firestore 查询

Nom*_*omi 1 firebase flutter google-cloud-firestore

我正在使用 Flutter (cloud_firestore) 并尝试在带有 title 的文档之后从 Firestore 获取数据'xxx',但它返回 0 结果。

return Firestore.instance.collection('products')
    .orderBy('title')
    .startAfter([{'title': 'xxx'}
]);
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?如何正确实现颤振分页?

Dun*_*nes 7

您应该传递一个值,而不是一个地图:

return Firestore.instance.collection('products')
    .orderBy('title')
    .startAfter(['xxx']);
Run Code Online (Sandbox Code Playgroud)

这方面的文档不是特别清楚。

  • 您应该能够传递文档,这样即使多个文档共享相同的值,您也可以正确分页...我开始认为将 Firestore 与 flutter 结合使用是一个错误。 (3认同)