mongodb - using $geoNear gives "geo near accepts just one argument when querying for a GeoJSON point" when using maxDistance mongodb - using $geoNear gives "geo near accepts just one argument when querying for a GeoJSON point" when using maxDistance mongoose mongoose

mongodb - using $geoNear gives "geo near accepts just one argument when querying for a GeoJSON point" when using maxDistance


I had same issue and went through many many solutions but any of them didn't work as thereal issue was in data.

In My Model had 2dsphere index which was correct but when using 2dshpere the location in the database should be in format of location : [ lng, lat ] which was the main issue. as mongodb does not validate location array this format.

Verify both the data in DB and points specified while querying both should be correct format.

Hope it helps someone!