Stamplay / stamplay-js-sdk

:rocket: JavaScript SDK of Stamplay cloud platform
https://stamplay.com
MIT License
88 stars 18 forks source link

Stamplay.Query().near() not sorting by distance #40

Open aleixpellicer opened 8 years ago

aleixpellicer commented 8 years ago

This:

var query = new Stamplay.Query('object', 'photo').near('Point',  [ 41.273237238849845, 1.6969573974609098 ], 900000, 0 );
query.exec().then(function(response){
  console.log(response.data);
});

should not only select within the given distances, but also sort by distance according to mongodb documentation:

The following example returns documents that are at least 1000 meters from and at most 5000 meters from the specified GeoJSON point, sorted from nearest to farthest:

   {
     location:
       { $near :
          {
            $geometry: { type: "Point",  coordinates: [ -73.9667, 40.78 ] },
            $minDistance: 1000,
            $maxDistance: 5000
          }
       }
   }
)```
criroselli commented 8 years ago

Hi @aleixpellicer, do you have a sort problem with this method ? Can you share with me more informations ?