Skip to content

Commit f26416f

Browse files
committed
fixing some docs related to sort query structure
1 parent 3504e61 commit f26416f

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

doc/query-format/query.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,27 @@ are available within `filter`.
3838

3939

4040
@param {String} [sort] The `sort` property is an optional value specifying:
41+
4142
- the property used to sort the results of a query, and
42-
- the direction of the sort (`asc` for ascending or `desc` for descending).
43+
- the direction of the sort (start the value with `-` for descending).
44+
45+
The sort property is specified as a string like `sort: "age"`. `sort: "age"`
46+
will return results ascending by the `age` property. `sort: "-age"` will return
47+
results descending by the `age` property.
48+
49+
This format follows [JSON API's recommendations](http://jsonapi.org/format/#fetching-sorting)
50+
on sorting. However, `can-query-logic` can only sort by a single property currently.
4351

44-
The sort property is specified as a string like `"age desc"`. If there is no space,
45-
the sort is assumed to be `asc`.
4652

47-
The `sort` property defaults to `"ID_PROPERTY asc"` where `ID_PROPERTY` is the first
48-
id returned by [can-query-logic.prototype.identityKeys].
53+
The `sort` property defaults to `"ID_PROPERTY"` where `ID_PROPERTY` is the first
54+
identity property returned by [can-query-logic.prototype.identityKeys]. This is usually the first
55+
identity value on the schema passed to `new QueryLogic()`:
56+
57+
```js
58+
new QueryLogic({
59+
identity: ["_id"]
60+
}).identityKeys() //-> ["_id"]
61+
```
4962

5063
@param {{start: Number, end: Number}} [page] The optional `page` property selects a range of the sorted result. It's values are inclusive and begin at `0`. This means that:
5164

0 commit comments

Comments
 (0)