我似乎无意中发现了GeoFire的一个问题,因为我似乎无法过滤我的GeoFire查询。在我的平台上,用户创建帖子,他们的位置是用地火设置的,正因为如此,有可能有成千上万的帖子我不想在客户端过滤。
我想要orderByChild('created')和limitToLast('10'),这样在客户端就不会花太长时间。
到目前为止,我得到的是:
this.geoFire = new GeoFire(this.database.database.ref()
.child('location'))
this.geoFire.query({
center: [this.userLocation.lat, this.userLocation.lng],
radius: 7
})
.on('key_entered', (key, location, distance) => {
this.subscription = this.database.database.ref('/posts/'+key)
.orderByChild('created')
this.subscription.once('value', (snapshot) => {
this.postFeed.push(snapshot.val())
});
})但这似乎行不通。
我的位置数据库如下所示:

关于员额:

我做错了什么?为什么我不能过滤orderByChild('score') or 'created'
发布于 2018-04-16 23:40:46
Firebase查询根据指定的条件从特定位置检索(可能)多个子节点。您已经有了到达这个帖子的完整路径:database.ref('/posts/'+key)。您不能将已经知道要检索的帖子与根据条件查询帖子结合在一起。
您最好的选择是检索所有在范围内的帖子,然后过滤客户机上最近的10个帖子。
https://stackoverflow.com/questions/49867564
复制相似问题