wvteijlingen / Spine

A Swift library for working with JSON:API APIs. It supports mapping to custom model classes, fetching, advanced querying, linking and persisting.
MIT License
264 stars 109 forks source link

Add sorting based on custom attributes #133

Open koraykoska opened 7 years ago

koraykoska commented 7 years ago

As stated in the JSONAPI documentation:

Note: Although recommended, sort fields do not necessarily need to correspond to resource attribute and association names.

it is not required that sort fields are a valid resource field. I added addCustomAscendingOrder and addCustomDescendingOrder which don't fail if the provided attribute is not a valid field.

I also changed the router so that it does not fail if a custom value was provided.

I think this should be added to Spine as JSONAPI does not restrict us to have custom sort fields.