0

I'm having a real issue. I'm trying to do a query, limit, sort, etc. This is what I'm doing:

MyModel.find( { where: { "location": 
                       { "near": { "lat": "80", "lng": 80 }}
              },
              {  limit: 50, offset: 0, skip: 10,
                 sort: { "name": "asc" }
              }, 
              function(err, docs) {
                  var retval    = docs || [];
                  return cb(null, retval);
           });

What is the magic sauce to do limit, skip, and sort?

Any help is appreciated. Thanks

xangy
  • 1,185
  • 1
  • 8
  • 19
KingFish
  • 8,773
  • 12
  • 53
  • 81

2 Answers2

1

Try using the order property as shown in the documentation here:

https://docs.strongloop.com/display/public/LB/Order+filter

example.find({
 order: 'price DESC',
 limit: 3 });
JSimonsen
  • 2,642
  • 1
  • 13
  • 13
0
MyModel.find( { where: { "location": { "near": { "lat": "80", "lng": 80 }}},
            limit: 50,
            offset: 0, 
            skip: 10, 
            order: "name ASC"
          }, 
          function(err, docs) {
              var retval    = docs || [];
              cb(null, retval);
       });

I think this is the way it should look. try reading this and documentation under it: https://docs.strongloop.com/display/public/LB/Querying+data

xangy
  • 1,185
  • 1
  • 8
  • 19