y***@qq.com
y***@qq.com
  • 发布:2022-01-23 19:24
  • 更新:2022-11-16 18:11
  • 阅读:503

unicloud-db 地理位置的查询条件查询报错了,是不支持我的这种写法吗

分类:uniCloud
<unicloud-db ref='udb'   
            v-slot:default="{data,pagination,hasMore, loading, error, options}"   
            @error="onqueryerror"  
            :collection="colList"   
            :page-size="10">  
</unicloud-db>
colList() {  
                let where = {  
                    loc: db.command.geoNear({  
                        geometry: new db.Geo.Point(113.323809, 23.097732),  
                        minDistance: 100,  
                        maxDistance: 3000,  
                    })  
                }  
                return [  
                    db.collection('opendb-news-articles').where(where).getTemp(),  
                    db.collection('uni-id-users').field('_id,username,avatar_file').getTemp()  
                ]  
            }

本地调试错误:

"InternalServerError: errCode: InternalServerError | errMsg: Command failed with error 2 (BadValue): '$geoNear, $near, and $nearSphere are not allowed in this context' on server 192.168.146.77:3717. The full response is { \"operationTime\" : { \"$timestamp\" : { \"t\" : 1642936471, \"i\" : 15 } }, \"ok\" : 0.0, \"errmsg\" : \"$geoNear, $near, and $nearSphere are not allowed in this context\", \"code\" : 2, \"codeName\" : \"BadValue\", \"$clusterTime\" : { \"clusterTime\" : { \"$timestamp\" : { \"t\" : 1642936471, \"i\" : 15 } }, \"signature\" : { \"hash\" : { \"$binary\" : \"MF2Vcf7Tqtdchkq7lr/3QDvMsAU=\", \"$type\" : \"00\" }, \"keyId\" : { \"$numberLong\" : \"6993914952280965288\" } } } }"

2022-01-23 19:24 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com

请问现在支持了吗?

zege

zege

11月了 还没支持

DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

这种用法暂不支持。根本原因是联表查询属于聚合操作,聚合操作内不允许使用db.command.geoNear,而是要使用geoNear聚合阶段,我们看下怎么调整

  • k***@163.com

    请问现在在udb里面还有多表联查里面能够使用geoNear吗?如果不可以,有什么办法可以实现同样的效果?是需要在云函数里面使用聚合查询吗?

    2023-02-12 12:27

  • DCloud_uniCloud_WYQ

    回复 k***@163.com: udb组件内不可使用,已支持在js内调用geoNear聚合阶段

    2023-02-13 11:02

linnian

linnian

我知道,没支持

要回复问题请先登录注册