找到原因了,不能用稳定版的开发工具,必须用开发版的,在云开发界面里会有地点类型的索引可以创建
unable to find index for $geoNear query- 当前 Bug 的表现(可附上截图) [图片] [图片] [图片] [图片] - 预期表现 - 复现路径 - 提供一个最简复现 Demo const db = wx.cloud.database({ env: app.globalData.envstr }) db.collection('SalePlace').where({ FPoint: db.command.geoNear({ geometry: db.Geo.Point(113.323809, 23.097732), //res.longitude, res.latitude), maxDistance: 5000, minDistance:1000, }) }).get().then(console.log)
2019-05-06 _是代指db.command,你没抄前面的代码吧..........
在云函数中使用 geoNear时报如下错误- 当前 Bug 的表现(可附上截图) - 预期表现 - 复现路径 - 提供一个最简复现 Demo 我存坐标的字段时 loc,已添加了索引 请问要使用geoNear ,那么字段是否要做特殊索引 返回结果: {"errorCode":1,"errorMessage":"user code exception caught","stackTrace":"errCode: -502001 database request fail | errMsg: [FailedOperation.Query] (BadValue) failed on: cmgo-74jngqhb_0 :: caused by :: error processing query: ns=tnt-69ax8l27s.usersTree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0\nSort: {}\nProj: {}\n planner returned error: unable to find index for $geoNear query; "} 日志: START RequestId: 1024d995-6734-11e9-b8ec-525400681fe1 Event RequestId: 1024d995-6734-11e9-b8ec-525400681fe1 2019-04-25T08:28:11.839Z 1024d995-6734-11e9-b8ec-525400681fe1 { latitude: 25.030724, longitude: 121.520076 } Error: errCode: -502001 database request fail | errMsg: [FailedOperation.Query] (BadValue) failed on: cmgo-74jngqhb_0 :: caused by :: error processing query: ns=tnt-69ax8l27s.usersTree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0 Sort: {} Proj: {} planner returned error: unable to find index for $geoNear query; at new CloudSDKError (/var/user/node_modules/wx-server-sdk/index.js:6166:28) at Object.returnAsCloudSDKError (/var/user/node_modules/wx-server-sdk/index.js:6218:16) at Object.checkError (/var/user/node_modules/wx-server-sdk/index.js:1484:23) at Query.<anonymous> (/var/user/node_modules/wx-server-sdk/index.js:1550:41) at step (/var/user/node_modules/tslib/tslib.js:133:27) at Object.next (/var/user/node_modules/tslib/tslib.js:114:57) at fulfilled (/var/user/node_modules/tslib/tslib.js:104:62) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) END RequestId: 1024d995-6734-11e9-b8ec-525400681fe1 Report RequestId: 1024d995-6734-11e9-b8ec-525400681fe1 Duration:53ms Memory:256MB MaxMemoryUsed:1.234375MB
2019-04-30要用 var year =(new Date(sdate)).getFullYear()这样子吗?是不是不能识别Date类型的参数需要强制转换一下?
自带的函数也运行不了?- 当前 Bug 的表现(可附上截图) [图片] [图片] - 预期表现 Year:2019 - 复现路径 - 提供一个最简复现 Demo function addYear(sdate, syear) { console.log('curDate:' + sdate) var year = sdate.getFullYear() console.log('Year:' + year) var month = sdate.getMonth() + 1 var day = sdate.getDate() var hour = sdate.getHours() var minute = sdate.getMinutes() var second = sdate.getSeconds() return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') }
2019-04-19突然又可以了。当时提示错误的环境ID,没截图。 现在又有新问题,获取不到数据: [图片] [图片] [图片] 找到了,是权限的问题。。。。。。
云数据库不能初始化- 需求的场景描述(希望解决的问题) 为什么我连接云数据库总是提示:Invalid env? [图片][图片] [图片] - 希望提供的能力
2019-04-11