So I'm trying to have Baasbox sort my query by distance and I'm unable to do so no matter what I try. Here is my code, I've tried numerous variations of it, but I can't' get it to give me an array sorted by distance....
Please help...
Thank you
NSString *fields = [NSString stringWithFormat:@"user,distance(lat,long,%f, %f) < 5 as dist", self.myLat, self.myLong];
NSDictionary *parameters = @{kPageNumberKey : @0, kPageSizeKey : @3, @"fields": distanceKey, @"orderBy":@"dist desc" };
[PFPost getObjectsWithParams:parameters
completion:^(NSArray *pois, NSError *error) {
if (error == nil) {
NSMutableArray *data = [[NSMutableArray alloc]initWithArray:pois];
self.data = data;
[self.tableView reloadData];
} else {
// deal with error
}
}];
http://localhost:9000/document/test_distance?where=distance(lat,long,43.722839,10.401689) < 5
http://localhost:9000/document/test_distance?fields=user, distance(lat,long,43.722839,10.401689) as dist&where=distance(lat,long,43.722839,10.401689) < 5&orderBy=dist descselect user, distance(lat,long,43.722839,10.401689) as dist from test_distance where distance(lat,long,43.722839,10.401689) < 5