.sort(string)

Purpose

Parameters

Description Accepted Data Types Required ?
1 Sort String string Yes

Example Usage

  1. var myQuery = User.find();
  2. var sortString= 'name ASC';
  3. // Sort strings look like this
  4. // '<Model Attribute> <sort type>'
  5. myQuery.sort('name ASC');
  6. myQuery.exec(function callBack(err,results){
  7. console.log(results)
  8. });

Notes

The .find() method returns a chainable object if you don’t supply a callback. This method can be chained to .find() to further filter your results.

Other Sort Types include

  • ASC
  • DESC