You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/query-format/query.md
+18-5Lines changed: 18 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -38,14 +38,27 @@ are available within `filter`.
38
38
39
39
40
40
@param {String} [sort] The `sort` property is an optional value specifying:
41
+
41
42
- 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.
43
51
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`.
46
52
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
+
newQueryLogic({
59
+
identity: ["_id"]
60
+
}).identityKeys() //-> ["_id"]
61
+
```
49
62
50
63
@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:
0 commit comments