-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multiple sort columns #56
base: master
Are you sure you want to change the base?
Add multiple sort columns #56
Conversation
@@ -180,5 +180,6 @@ In addition to the filter parameters, there is a set of query parameters that ha | |||
| `eager=[children, parent.movies]` | Which relations to fetch eagerly for the result models. An objection.js relation expression. | | |||
| `orderBy=firstName` | Sort the result by certain property. | | |||
| `orderByDesc=firstName` | Sort the result by certain property in descending order. | | |||
| `orderByAsc=group\|lastName` | Sort the result by more than one property in ascending order. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems not very RESTful. Can you adjust the param structure to follow either
?foo=bar&foo=qux
or
?foo=bar,qux
, as suggested in https://medium.com/raml-api/arrays-in-query-params-33189628fa68 ?
@@ -180,5 +180,6 @@ In addition to the filter parameters, there is a set of query parameters that ha | |||
| `eager=[children, parent.movies]` | Which relations to fetch eagerly for the result models. An objection.js relation expression. | | |||
| `orderBy=firstName` | Sort the result by certain property. | | |||
| `orderByDesc=firstName` | Sort the result by certain property in descending order. | | |||
| `orderByAsc=group\|lastName` | Sort the result by more than one property in ascending order. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same should be documented for desc
sorting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments
Add ability to sort on multiple columns. I done this by extending the
orderBy
,orderByAsc
andorderByDesc
query parameters.Multiple columns can be delimited by the
|
character. I chose this character to be consistent with the way you specify multiple columns in the filter parameters.This was done in a backwards compatible way. All the existing unit tests still pass unmodified.
I have added two new unit tests to test this functionality.
I updated the readme.
In addition to this, I have also fixing a linting error I introduced in my previous merge request. I included this in a separate commit.