gpt4 book ai didi

javascript - 如何按附近的地理坐标对 Mongo 集合进行排序

转载 作者:行者123 更新时间:2023-11-30 16:54:27 25 4
gpt4 key购买 nike

我有以下 Mongo 调用,如何根据最近的地理坐标返回排序的地点列表?

Venues.find({'location.coordinates': 
{ $near :
{ $geometry :
{ type : "Point" ,
coordinates: params.coordinates }
},
$maxDistance : 10000
}
});

最佳答案

当您使用 $near 时,MongoDB 返回结果 sorted with nearest distance first by default .如果这是您不想要的,请改用 $geoWithin。

关于javascript - 如何按附近的地理坐标对 Mongo 集合进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29957005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com