如何解决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 举报,一经查实,本站将立刻删除。