Mongodb not $near

六眼飞鱼酱① 提交于 2019-12-11 06:39:23

问题


Let's say I have a collection in mongoDB with geoLocation indexed field (coordinates). I know I can query records nearby my location with something like

MySchema.find({coordinates: {$near: [100,100], $maxDistance: 500}, callback);

But what if I want to get those records away from my location (out of the circle around location)?? Is it possible? I have tried to use $not, but it returned empty results, but I know there are hundreds of records not near me.

I know there is this option to get nearby records, then select the ones {_id: {$not: {$in: nearby_ids_array}. But is it the only way, or am I missing something???

来源:https://stackoverflow.com/questions/14831402/mongodb-not-near

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!