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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DavidPayne-Woodscamp
Copy link
Contributor

Add ability to sort on multiple columns. I done this by extending the orderBy, orderByAsc and orderByDesc 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.

@@ -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. |
Copy link
Collaborator

@kibertoad kibertoad Apr 1, 2020

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. |
Copy link
Collaborator

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.

Copy link
Collaborator

@kibertoad kibertoad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants