我正在尝试对 mongodb 集合使用 mongoose 地理空间查询。“2dsphere”索引已应用于位置对象。
询问
请在下面找到查询:
const data = await Banks.find(
{
location: {
$near: {
$geometry: {
type: "Point",
coordinates: [73.8567, 18.5204]
},
$maxDistance: 10000000
}
}
}
);
console.log('-- the data --', data);
数据
许多文档之一如下所示:
{
"_id" : ObjectId("5c64511a04ede20c28f6ef0b"),
"location" : {
"coordinates" : [
92.747338,
11.675442
],
"type" : "Point"
},
"name" : "Test name",
}
我试过的
我试图将最大距离设置得尽可能大。但是查询不会检索任何文档。可能是什么问题呢?