Firestore分页-查询后如何查找是否有更多数据(使用限制) [英] Firestore pagination - how to find if there are more data after query (using limit)

查看:34
本文介绍了Firestore分页-查询后如何查找是否有更多数据(使用限制)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在当前的python 2.7标准环境中使用ndb数据存储.我们将这个应用程序迁移到具有Firestore(本机模式)的python 3.7标准环境中.

We use ndb datastore in our current python 2.7 standard environment. We migrating this application to python 3.7 standard environment with firestore (native mode).

我们在ndb数据存储上使用分页,并使用访存来构造查询.

We use pagination on ndb datastore and construct our query using fetch.

 query_results , next_curs, more_flag = query_structure.fetch_page(10)

next_curs和more_flag在指示当前查询之后(要获取10个元素)是否有更多数据要获取时非常有用.我们用它来标记下一页"/上一页"的前端.

The next_curs and more_flag are very useful to indicate if there is more data to be fetched after the current query (to fetch 10 elements). We use this to flag the front end for "Next Page" / "Previous Page".

我们在Firestore中找不到与之相当的产品.有人可以帮助实现这一目标吗?

We can't find an equivalent of this in Firestore. Can someone help how to achieve this?

推荐答案

Firestore分页中没有直接等效项.相反,您可以执行的操作是,获取比该页面所需的N个文档多的一个文档,然后使用N + 1个文档的存在来确定是否存在更多".您将在显示的页面中省略N + 1文档,然后从该N + 1文档开始下一页.

There is no direct equivalent in Firestore pagination. What you can do instead is fetch one more document than the N documents that the page requires, then use the presence of the N+1 document to determine if there is "more". You would omit the N+1 document from the displayed page, then start the next page at that N+1 document.

这篇关于Firestore分页-查询后如何查找是否有更多数据(使用限制)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆