Skip to content

Default Sort#756

Merged
lgebhardt merged 1 commit intoJSONAPI-Resources:masterfrom
lgebhardt:default_sort_params
Jul 18, 2016
Merged

Default Sort#756
lgebhardt merged 1 commit intoJSONAPI-Resources:masterfrom
lgebhardt:default_sort_params

Conversation

@lgebhardt
Copy link
Copy Markdown
Contributor

Moves the setting of the default sort from the request_parser to a method on the resource, named default_sort.

This is an alternative to #752

Moves the setting of the default sort from the request_parser to a method on the resource, named default_sort.
@jagthedrummer
Copy link
Copy Markdown
Contributor

Was just looking for a way to do this. PR looks great!

@lgebhardt lgebhardt merged commit 7b73952 into JSONAPI-Resources:master Jul 18, 2016
@krainboltgreene
Copy link
Copy Markdown

A default sort of id makes no sense on UUIDs. They cannot be meaningfully sorted.

@lgebhardt
Copy link
Copy Markdown
Contributor Author

A default sort of id makes no sense on UUIDs. They cannot be meaningfully sorted.

@krainboltgreene Agreed. Here was my thought process in choosing id. We need a default sort to, at a minimum, make pagination consistent. id is the only field JR requires, so it became the default, by default.

This will work well enough for the simple systems that use counter based ids. For systems using GUIDs you will want to set the default sort to something like created_at, though this will vary from project to project

I'm open to other ideas.

@lgebhardt lgebhardt deleted the default_sort_params branch August 23, 2018 16:49
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.

3 participants