Firestore中的PageInfo不可用

huangapple go评论88阅读模式
英文:

PageInfo in Firestore not usable

问题

我想在Firestore中使用分页功能,这样我就可以保存查询状态,并自动允许用户提交一个页面令牌来重新开始查询。我在这方面遇到的挑战是,Firestore没有提供查询令牌或页面令牌来恢复迭代。然而,在查看GoLang文档后,我发现有一个导出的PageInfo()方法,它返回了我感兴趣的令牌,还有一个未导出的fetch方法

是否有一种方法可以使用导出的PageInfo()值,使用现有的令牌获取一组新的文档?

英文:

I would like to use pagination in Firestore so I can save a query state and automatically allow users to submit a page token to start a query again. The challenge I am seeing with this is that Firestore does not offer a query token or page token to resume iteration. However, after looking through the docs for GoLang, it looks like there is an exported PageInfo() method that returns a token I am interested in and an unexported fetch method.

Is there a method to use the exported PageInfo() values to allow me to fetch a new set of documents using that existing token?

答案1

得分: 1

在Firestore数据库中使用分页,你可以使用查询游标和limit()方法,如此文档所述。你可以通过此YouTube链接了解更多信息。

你还可以考虑使用pageSizepageToken查询参数以及Firestore REST API中的nextPageToken字段,如此文档所述,以实现分页。有一个类似的StackoverFlow线程可能对你有帮助。

英文:

To use pagination in Firestore Database you can use query cursors with limit() method as mentioned in this document. You can go through this youtube link to know more about it.

You may also consider using pageSize & pageToken query parameters and nextPageToken field with Firestore REST API as mentioned in this document to achieve pagination. There is a similar StackoverFlow thread which may help you.

huangapple
  • 本文由 发表于 2021年8月14日 13:43:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/68780677.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定