Skip to content

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.

| `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 ?

| `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