英文:
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链接了解更多信息。
你还可以考虑使用pageSize
和pageToken
查询参数以及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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论