Previous Page Arrow Next Page Arrow

6.3 Query Sorting

URL

The sorting criteria MUST be passed via the orderBy query parameter. For example:

GET /sdata/myApp/myContract/-/salesOrders?orderBy=orderDate desc

The orderBy parameter MAY list several criteria separated by commas. For example, orders can be sorted by descending date and then by ascending order id with the following query:

GET /sdata/myApp/myContract/-/salesOrders?orderBy=orderDate desc,orderId asc

Metadata

In the schema, the properties that can be used to sort SHOULD be flagged with the canSort attribute. For example:

<xs:element name="orderDate" type="xs:date"
            sme:label="Date" sme:canSort="true" sme:canFilter="true" sme:precedence="2" />
SData providers MUST support sorting on all the properties flagged with sme:canSort="true". SData providers SHOULD support multiple criteria, but there MAY be restrictions in this area. The list of keys may be constrained to match the columns of a database index for example. This should be advertised via documentation in the schema, as there are no SME attributes for these constraints. If the provider cannot handle the combination of criteria specified by the consumer, it SHOULD NOT return an error. Instead, it SHOULD apply the subset of criteria that it can handle and it SHOULD add a <diagnosis> element to the response feed, with a warning describing what it could not handle.

Previous Page Arrow Next Page Arrow