dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 377 forks source link

multiple sort #537

Closed ddo closed 9 years ago

ddo commented 10 years ago

Is there any way to do sort by multiple property/column ?

nyshporka commented 9 years ago

You can sort by multiple fields using something like:

         User.find({}, ['age', '-name', 'id'], function (err, users) {
         });

Where you using Array of needed arguments and '-' before for sorting this field backwards. You probably try to have not a fields named 'A' or 'Z' - this may cause bugs in multiple sorting though