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 pagination and metadata in a V2 #29

Open
rafaell-lycan opened this issue Nov 15, 2017 · 3 comments
Open

Add pagination and metadata in a V2 #29

rafaell-lycan opened this issue Nov 15, 2017 · 3 comments
Labels

Comments

@rafaell-lycan
Copy link

Hey, by now it's possible to collect data from 10 pages and the only filter so far is page=Number.

In a near future perhaps a good idea could be put some extra filters and also return data about the pagination.

{
  data: []
  meta: {
    // Whatever you want....
  }
}
@cheeaun
Copy link
Owner

cheeaun commented Nov 15, 2017

Two questions:

  1. What kind of extra filters do you have in mind?
  2. Can you give me an example for the pagination data that can be returned?

Thanks!

@rafaell-lycan
Copy link
Author

Hey,

1/2. I was imagining something like filters for pagination mostly, but then you can think about filter by specific property like type, points, etc... or return the only properties that you need by passing something like ?fields=opt1,opt2,opt3... and even put a kinda order by if you want.

If you want, you can take a look at the Angolia example.

api/v2/<resource>?page=2&size=20

{
  items: [] // it could be "results", "data" or even the resource name in plural too.
  meta: { // it could be metadata, _meta, _metadata
    page: 2, // or pageNumber
    per_page: 20, // or "size".... btw default: 30?
    total_count: 100 // or just "total"
  }
}

In the "metadata", you could also include next/prevPage or change all for a more SQL like properties such offset, limit and total.

In the return of the objects you could explore use HATEOAS and also put some sub resources like apì/v2/items/3338485/comments.

Also it's a great opportunity to refactor the application, both code and app structure.

@rafaell-lycan
Copy link
Author

@cheeaun it makes sense for you?

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

No branches or pull requests

2 participants