限制从GeoFire查询的项目数量 [英] Limit the number of queried items from GeoFire

查看:135
本文介绍了限制从GeoFire查询的项目数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一个地方有很多条目。我只想使用Geofire获得10个最新添加的项目。我知道使用Query.limitToLast()可以轻松地使用firebase完成,但是我不知道如何使用Geofire来完成。



如果不可能,你有任何解决方法,我可以申请?

解决方案

只有一个解决方案:



你应该开始一个半径小的查询,每次到达GeoQueryReady()(所有数据已经​​被加载) ,使用.setRadius(r)增加一小部分的地理位置,直到达到你想要的限制



基于这个 https://github.com/firebase/geofire-js/issues/59


I have a lot of entry in the same location. I would like only to get the 10 latest added items using Geofire. I know that it can be done easily with firebase using Query.limitToLast() but I don't know how to do it with Geofire.

If it is not possible, do you have any workaround that I can apply ?

解决方案

There is only one solution for this :

you should begin a query with a small radius,

and each time you reach onGeoQueryReady() ("All data has been loaded"), you increase the radius by a small amount of the geoquery with .setRadius(r) until you reach the limit you want

based on this https://github.com/firebase/geofire-js/issues/59

这篇关于限制从GeoFire查询的项目数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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