q***@163.com
q***@163.com
  • 发布:2022-05-31 11:11
  • 更新:2022-06-06 14:29
  • 阅读:374

unicloud 使用geoNear报错,照搬的官方文档代码。有大佬帮忙看一下嘛

分类:uniCloud

exports.main = async (event, context) => {
const db = uniCloud.database(),
dbCmd = db.command,
$ = db.command.aggregate
let res = await db.collection('testMsg').aggregate()
.geoNear({
distanceField: 'distance', // 输出的每个记录中 distance 即是与给定点的距离
spherical: true,
near: new db.Geo.Point(113.3089506, 23.0968251),
query: {
docType: 'geoNear',
},
key: 'location', // 若只有 location 一个地理位置索引的字段,则不需填
includeLocs: 'location', // 若只有 location 一个是地理位置,则不需填
})
.end()

return res  

};

错误信息

11:06:00.964 [本地运行]Error: errCode: DATABASE_REQUEST_FAILED | errMsg: [FailedOperation] Failed operation. Please check your request, but if the problem persists, contact us.
11:06:00.966 [本地运行] at D:\HBuilderX\plugins\unicloud\tcb\@dcloudio\serverless\lib\tcb\uni-cloud.js:1:972
11:06:00.966 [本地运行] at processTicksAndRejections (internal/process/task_queues.js:97:5)

2022-05-31 11:11 负责人:无 分享
已邀请:
q***@163.com

q***@163.com (作者)

dd来个大佬

DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

建立地理位置索引了吗?

要回复问题请先登录注册