我想找到[2,2.01]的最近点,我输入的查询句子如下,但是,它给了我一条错误信息:geo near query中的无效参数:球形,详细信息可以在下面找到
> db.places.find()
{ "_id" : ObjectId("5892a41f8c4ec25d8bf6bc61"), "log" : [ 2, 2 ] }
{ "_id" : ObjectId("5892a4298c4ec25d8bf6bc62"), "log" : [ 4, 2 ] }
{ "_id" : ObjectId("5892a43a8c4ec25d8bf6bc63"), "log" : [ 1, 1 ] }
{ "_id" : ObjectId("5892a4448c4ec25d8bf6bc64"), "log" : [ 2, 5 ] }
{ "_id" : ObjectId("5892a44f8c4ec25d8bf6bc65"), "log" : [ -20, 23 ] }
{ "_id" : ObjectId("5892a45f8c4ec25d8bf6bc66"), "log" : [ 40.757699, -73.987632 ] }
> db.place.find( { log:
... { $near : { $geometry :
... { type: "Point", coordinates : [2, 2.01]},
... spherical : true
... }
... }})
Error: error: {
"ok" : 0,
"errmsg" : "invalid argument in geo near query: spherical",
"code" : 2,
"codeName" : "BadValue"
}
答案 0 :(得分:0)
考虑使用猫鼬
let memos = await Memo.find({})
.where('loc')
.near({
center: {
type: 'Point',
coordinates: [parseFloat(lng), parseFloat(lat)],
spherical: true,
maxDistance: 2
}
})
.select('img loc')
.limit(30)