0

In the docs Strongloop does not talk about a common condition: using a WHERE filter with a Order filter.

Example: Customers WHERE name='John' ORDER BY 'birthdate' DESC LIMIT 5

Customers.find({where:{'userId':'John'},{order:'birthdate DESC',limit:5}},...

Anyone have the right syntax? It runs but it's not giving the right answer. It's not applying the ORDER filter nor the limit filter.

Thank you

user798719
  • 9,619
  • 25
  • 84
  • 123

1 Answers1

1

Order and limit are two properties of the object send to find, you merged limit and order into a subdocument. You should use:

  Customers.find({ 
    where: { 'userId': 'John' },
    order: 'birthdate DESC', //can take array of string if multiple order
    limit: 5
  });

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

Jonathan Muller
  • 7,348
  • 2
  • 23
  • 31