Parse.Query.each () not including all records

I see a bug in the latest javascript package for Parse (v 1.4.2) that Parse.Query.each () doesn't seem to get through, though all relevant entries. It seems to have stopped after a certain point.

I have a UserLocation class that stores the geolocations of user locations (in the "geo" column). I am trying to find a list of user locations that are less than 10 miles away. As I understand it, Parse.Query.find () has a limit of 1000. According to this post, Parse.Query.each () has no such limit: https://parse.com/questions/pfquery-setskip-does-not-skip- beyond-10000

But it doesn't seem to be the case, judging by my results:

mylocation.get("deviceId")
"fa72f38bc0af44f090824a38fd1963b4"
venueGeo.milesTo(mylocation.get("geo"));
2.1965871191375173

      

As you can see, my location is about 2 miles from the venue. But if I run a request for a distance of 10 miles, the result doesn't have my location:

var locationQuery = new Parse.Query("UserLocation").withinMiles("geo", venueGeo, 10);
results = [] ;
locationQuery.each(function(location) {results.push(location.get("deviceId"))})
b.Promise {_resolved: false, _rejected: false, _resolvedCallbacks: Array[0], _rejectedCallbacks: Array[0], resolve: function…}
results.length
107
results.indexOf("fa72f38bc0af44f090824a38fd1963b4")
-1

      

But if I add an additional query constraint to return records whose deviceId is equal to my location. Parse.Query.each () actually includes it. The new request id will only return subsets of the previous request. But its actually returning a record that is not in the previous request:

var locationQuery = new Parse.Query("UserLocation").withinMiles("geo", venueGeo, 10).equalTo("deviceId", "fa72f38bc0af44f090824a38fd1963b4");
results = [] ; 
locationQuery.each(function(location) {results.push(location.get("deviceId"))})
b.Promise {_resolved: false, _rejected: false, _resolvedCallbacks: Array[0], _rejectedCallbacks: Array[0], resolve: function…}
results.length
1
results.indexOf("fa72f38bc0af44f090824a38fd1963b4")
0

      

If I go through the posts using Parse.Query.limit (1000) and Parse.Query.skip () I finally found my post on page 8

locationQuery.skip(7000)
locationQuery.find().then(function(locations){
  results = locations.map(function(location){
    return location.get("deviceId");
  })
})
results.indexOf("fa72f38bc0af44f090824a38fd1963b4")
-1

locationQuery.skip(8000)
locationQuery.find().then(function(locations){
  results = locations.map(function(location){
    return location.get("deviceId");
  })
})
results.indexOf("fa72f38bc0af44f090824a38fd1963b4")

927

      

But paging has its limitations as you can't miss more than 10,000 entries, let alone less efficient.

This seems to contradict what the Parse javascript Documentation says Parse.Query.each () has no limit. Does anyone face the same problem?

+3


source to share


1 answer


I don't see in the docs where we are told that each () does not qualify for the 1k limit, but it is reasonable that it will not. The presented code displays calls and responses that, in my opinion, may be subject to a race condition, that is, each promise may not be fulfilled at the time of measuring the results. Here's a deterministic test that might well find the entry:



var locationQuery = new Parse.Query("UserLocation");
locationQuery.withinMiles("geo", venueGeo, 10);
results = []; 
locationQuery.each(function(location {
    results.push(location.get("deviceId"));
}).then(function() {
    console.log("results length=" + results.length);
    console.log("index of target device id=" + results.indexOf("fa72f38bc0af44f090824a38fd1963b4"));
});

      

0


source







All Articles