taro云开发小程序geoNear查询报错



  • 如题,使用taro开发微信小程序,云端数据库对location字段加索引,查询报错,具体信息如下图
    7d208f79-d3fc-4566-9e48-3a716c072513-image.png

    云端数据库信息:
    ad3eef61-6c31-49a4-92cd-e19c71462728-image.png

    索引:
    193d0b7d-1dfe-4637-a139-ce95b5dfdd9a-image.png

    本地代码如下:

    const collection = db.collection('house')
    const { latitude, longitude } = event
    let nearbyList = []
    try {
    nearbyList = (await collection.where({
    location: db.command.geoNear({
    geometry: db.Geo.Point(longitude, latitude),
    minDistance: 100,
    maxDistance: 2000,
    })
    }).get()).data
    if (!nearbyList.length) {
    nearbyList = (await collection.limit(10).get()).data
    }
    } catch (error) {
    console.log(error)
    nearbyList = (await collection.limit(10).get()).data
    }

    求大佬解惑!


登录后回复