-
Notifications
You must be signed in to change notification settings - Fork 0
SQL Like: Order By
joelwatson edited this page May 19, 2015
·
1 revision
CriteriaBuilder allows you to influence the order of store/collection results in a very SQL-like way:
ORDER BY {propertyName} {direction [ASC/DESC]} SELECT orderNumber ORDER BY orderDate DESC
Multiple sorters can be added by providing a comma-delimited list of property/direction combinations:
ORDER BY {propertyName} {direction [ASC/DESC]}, {propertyName} {direction [ASC/DESC]}, ... SELECT orderNumber JOIN user u ORDER BY orderDate DESC, u.lastName ASC
NOTE: As with joins and criteria, sorting on association fields will require the inclusion of the join alias in the property name (see above).
var cb = new CriteriaBuilder.Builder({ store: mystore }); var sql = 'select u.lastName, orderId, orderNumber num join user u order by orderDate DESC, u.lastName ASC'; // run cb.query({sql:sql});