【发布时间】:2019-04-05 05:58:40
【问题描述】:
我在下面有以下 Firestore 查询。我正在尝试执行多个 在哪里查询 Book 集合。我想按书名和书年龄范围过滤。但是我收到以下错误
“onsnapshot firebaseError 中未捕获的错误:光标位置超出了原始查询的范围”有人可以建议。
const collectionRef = firebase.firestore().collection('Books')
collectionRef.where('d.details.BookType',"==",BookType)
collectionRef = collectionRef.where('d.details.bookage',"<=",age)
collectionRef = collectionRef.orderBy('d.details.bookage')
const geoFirestore = new GeoFirestore(collectionRef)
const geoQuery = geoFirestore.query({
center: new firebase.firestore.GeoPoint(lat, long),
radius: val,
});
geoQuery.on("key_entered",function(key, coords, distance) {
storeCoordinate(key,coords.coordinates._lat,coords.coordinates._long,newdata)
});
【问题讨论】:
-
您是否尝试过使用
const geoFirestore = new GeoFirestore(collectionRef.where('d.details.BookType',"==",BookType).where('d.details.bookage',"<=",age).orderBy('d.details.bookage'))之类的链式调用来代替const geoFirestore = new GeoFirestore(collectionRef)? -
我刚试过,但它不起作用我不确定问题是什么。
-
你的行为是否与上述解决方案相同?
-
是的,错误消息与初始错误相同。你能复制吗?
-
我相信 orderBy 语法会导致问题,但是我确实需要 order by,因为我正在对书龄进行过滤。
标签: react-native google-cloud-firestore