Closed
Description
I tried to add a $geoWithin
constraint to a Parse.Query
like so:
var query = new Parse.Query("MyCollection");
var jsonQuery = query.toJSON();
jsonQuery.where.location = {
"$geoWithin": {
"$centerSphere": [
[geoPoint.longitude, geoPoint.latitude],
10 / 6371.0
]
}
};
query.withJSON(jsonQuery);
It throws the error:
bad $geoWithin value; $polygon should contain at least 3 GeoPoints.
The reason is apparently that Parse Server's Mongo Transformer only accepts a polygon parameter with $geoWithin
.
The advantage of a $geoWithin.$centerSphere
constraint vs. the existing withinKilometers
constraint is that is is not using $near
to sort the results by distance and therefore executed faster.
How can I add a query constraint that limits the results to documents with a location field within a certain radius in km of a geo coordinate?
If not I'll do to a PR.
Metadata
Metadata
Assignees
Labels
No labels