i have collection 2dsphere index , want use $geowithin , $centersphere functions query it.
excerpt of model:
{ // ... coordinates: { coordinates: { type: array, index: '2dsphere' } } // ... } i inserted bunch of documents database , try query via:
model.find({ coordinates: { coordinates: { $geowithin: { $centersphere : [ [ lng, lat], r ] } } } }) the problem facing is, call not return anything, neither error, nor data. tried in mongo shell in node.js application longitudes , latitudes of objects can confirm inserted database. tried use $near $maxdistance same result. furthermore switched latitude , longitude check...and convert r radians dividing earth's radius.
i out of ideas on goes wrong @ point , thankful suggestions!
i think should change model but, use "dot notation" instead:
model.find({ "coordinates.coordinates": { "$geowithin": { "$centersphere" : [ [ lng, lat], r ] } } },function(err,callback) { });
Comments
Post a Comment