New topic Closed topic
avatar image
1
Order collection based on input
By Created , last editted

Hi there,

I am working on a application in which I create a couple of JSON Endpoint that shows a collection of data. I am using limit and offset to be able to control the amount of data to be able to implement pagination later on. So far so good as stated in the example below:

appname.bettywebblocks.com/api/data-to-show?limit=10&offset=10

But I also want to be able to dynamically order the collection the property, that is given, like this:

ascending: appname.bettywebblocks.com/api/data-to-show?limit=10&offset=10&sort=name 

descending: appname.bettywebblocks.com/api/data-to-show?limit=10&offset=10&sort=-name

Possible options that come in mind:

  • Creating separate collections per sort column and sort order (not exactly what I want to do)
  • Implement the offset, limit and sort in the endpoint template using liquid (testing this out right now)

Is there someone who has done this before and can share their insights? 


Hi there,

I am working on a application in which I create a couple of JSON Endpoint that shows a collection of data. I am using limit and offset to be able to control the amount of data to be able to implement pagination later on. So far so good as stated in the example below:

appname.bettywebblocks.com/api/data-to-show?limit=10&offset=10

But I also want to be able to dynamically order the collection the property, that is given, like this:

ascending: appname.bettywebblocks.com/api/data-to-show?limit=10&offset=10&sort=name 

descending: appname.bettywebblocks.com/api/data-to-show?limit=10&offset=10&sort=-name

Possible options that come in mind:

  • Creating separate collections per sort column and sort order (not exactly what I want to do)
  • Implement the offset, limit and sort in the endpoint template using liquid (testing this out right now)

Is there someone who has done this before and can share their insights? 

Answers
Sort by:

This topic is closed.