在Firebase Firestore中使用外部排序而不使用使用的查询不等式 [英] Using external orderby without using used query inequality in firebase firestore
问题描述
无论如何,在这个位置上我是否能以第一订单的身份逃脱GeoPoint? 如果我从orderby中删除GeoPoint,则会触发以下错误;如果按照以下说明将GeoPoint设置为第一个orderby,则会误导第二个orderby priceSort.
Is there anyway i can escape GeoPoint as first order in this postion? If i remove GeoPoint from orderby it triggered the below error and if i put the GeoPoint as first orderby, as instructed as below, it mislead the second orderby priceSort..
未捕获的错误:无效的查询.你有一个where过滤器 在'GeoPoint'字段上具有不等式(<,< =,>或> =) 还必须使用"GeoPoint"作为您的第一个Query.orderBy(),但您的第一个 Query.orderBy()放在字段"priceSort"上.
Uncaught Error: Invalid query. You have a where filter with an inequality (<, <=, >, or >=) on field 'GeoPoint' and so you must also use 'GeoPoint' as your first Query.orderBy(), but your first Query.orderBy() is on field 'priceSort' instead.
const locations=NearBy({
center:{
latitude:4*.*****,
longitude:7*.*****},
radius:30000})
var db = firebase.firestore();
var AdsQry = db.collection("ads");
AdsQry = AdsQry
.where('GeoPoint', '>', locations.lesserGeopoint)
.where('GeoPoint', '<', locations.greaterThan)
.orderBy('GeoPoint', 'asc');
AdsQry = AdsQry.where('complete', '==', 'yes')
//.where('countrycode', '==', 'IT')
.orderBy('priceSort', 'desc')
AdsQry.get().then(function(snapshot) {
snapshot.forEach((doc) => {
console.log(doc.id+": priceSort="+doc.data().priceSort+" dateSort="+doc.data().dateSort);
})
})
推荐答案
您是否尝试过这样做:
AdsQry
.where('GeoPoint', '>', locations.lesserGeopoint)
.where('GeoPoint', '<', locations.greaterThan)
.where('complete', '==', 'yes')
//.where('countrycode', '==', 'IT')
.orderBy('GeoPoint')
.orderBy('priceSort', 'desc')
这是链接到文档
这篇关于在Firebase Firestore中使用外部排序而不使用使用的查询不等式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!