调试基础库2.8.1
const db = wx.cloud.database()
const pxgps = db.command
db.collection(‘shops’).where({location: pxgps.geoNear({geometry: db.Geo.Point(this.data.longitude, this.data.latitude),minDistance: 0,maxDistance: 5000,}).get({
success: res => {
let new_data = res.data
let old_data = this.data.products
console.log(“old_data:” + old_data)
this.setData({
products: old_data.concat(new_data),
page: page
})
},
})
在官方文档上面发现通过使用geoNear可以对以用户为中心的周边商户经纬度距离进行排序,然而实际上该方法一直报错,数据库中已经将location保存商家经纬度的字段设置了地理索引,但依然不行,在网上查了好几天,发现有问过这个问题的人,但一直都没有得到解决,已经重复检查了很多遍了,代码以及数据库索引应该都是没问题的,请问这到底是个BUG还是有其他要设置的地方?以下为报错信息
VM2208:1 thirdScriptError
pxgps.geoNear(…).skip is not a function; [Component] Event Handler Error @ pages/index/index#bound shopslist
TypeError: pxgps.geoNear(…).skip is not a function
at ye.shopslist (http://127.0.0.1:24671/appservice/pages/index/index.js:196:14)
at Object.r.safeCallback (WAService.js:1:1125173)
at WAService.js:1:1317978
at r (WAService.js:1:1249680)
at WAService.js:1:1249802
at WAService.js:1:420977
at n (http://127.0.0.1:24671/appservice/__dev__/asdebug.js:1:27852))
at e.exports.
at http://127.0.0.1:24671/appservice/__dev__/asdebug.js:1:1968
at Array.forEach (<anonymous>)
关于SKIP,不论我加不加都是一样还是会报错的,因此目前的报错与SKIP无关。希望能得到解决,谢谢