Firestore-在带有循环的位置创建查询

问题描述

我尝试获取房间,但有时我想使用循环动态创建许多X过滤器。实际上,当我的数组长于1时,它是行不通的。

let query = GeoFirestoreRoomref
            .where('state','==',1)
            .near({
                center: geoPoint(center.latitude,center.longitude),radius: geTradius(bounds.southWest.latitude,bounds.southWest.longitude,bounds.northEast.latitude,bounds.northEast.longitude) / 2,// We divide by two in order to have the radius of our screen and avoid recovering elements that will not be visible to the user
            })

        if (filters.length > 0) {
            for (let i = 0; i < filters.length; i++) {
                query = query.where('theme_id',filters[i])
            }
        }

当数组中有多个元素时,它不起作用似乎很奇怪。一开始,我尝试使用foreach,但是我进行了更改以确保它将是异步的。

你有什么主意吗?

PS:GeoFirestore不会感到惊讶,GeoFirestore is an open-source library that extends the Firestore library in order to store and query documents based on their geographic location.

感谢阅读!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)