代码如下
const _ = db.command
db.collection('point').where({
Geo: _.geoNear({
geometry: db.Geo.Point(117.229938, 39.100311),
maxDistance: 5000,
})
}).count().then(console.log)
报错如下
VM922:1 Uncaught (in promise) thirdScriptError
errCode: -502001 database request fail | errMsg: [FailedOperation.Query] (BadValue) $geoNear, $near, and $nearSphere are not allowed in this context
Error: errCode: -502001 database request fail | errMsg: [FailedOperation.Query] (BadValue) $geoNear, $near, and $nearSphere are not allowed in this context
at new u (http://127.0.0.1:30945/appservice/__dev__/WAService.js:2:233057)
at Function.success (http://127.0.0.1:30945/appservice/__dev__/WAService.js:2:284582)
at Object.success (http://127.0.0.1:30945/appservice/__dev__/WAService.js:2:126542)
at y (http://127.0.0.1:30945/appservice/__dev__/WAService.js:2:536042)
at v (http://127.0.0.1:30945/appservice/__dev__/WAService.js:2:536280)
at http://127.0.0.1:30945/appservice/__dev__/WAService.js:2:537834
at n.<anonymous> (http://127.0.0.1:30945/appservice/__dev__/asdebug.js:1:10216)
at http://127.0.0.1:30945/appservice/__dev__/WAService.js:2:126542
at http://127.0.0.1:30945/appservice/__dev__/WAService.js:2:109272
使用get时正常,使用count就报错
count 无法和 geo 一起使用