问题
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