Skip to content
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 Order By

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).

Example

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});
Clone this wiki locally