0

I have some Schools within my database with the Geolocation value set to {latitude: 0, longitude: 0}.

I want to query schools based on my user's location, which is t.GeoPoint {_latitude: 48.87513, _longitude: 2.3389439999999695}.

This is how I query them : var school_query = new Parse.Query("School");

  school_query.near("Geolocation", this.geopoint);
  school_query.limit(10);
  school_query.find().then(...)

The 10 Schools return have their Geolocation field set to {latitude: 0, longitude: 0}. Obviously, this is not what I want.

I tried all I could to exclude those Schools from the results, such as creating a {0:0} geopoint, and using notEqualTo it. I tried to limit the results to 10km around my user.

Nothing works, 0 valued schools are still returned first. Is there anyway to circumvent this without having to play with the data?

Any suggestion is most welcome!

Alexandre Bourlier
  • 3,972
  • 4
  • 44
  • 76

1 Answers1

1

If the geolocation is null then those objects will be ignored when there is a location based query constraint. My guess would be that this.geopoint doesn't have the lat/long pair values of {_latitude: 48.87513, _longitude: 2.3389439999999695} and isn't being initialized or accessed correctly.

Russell
  • 3,099
  • 2
  • 14
  • 18