Add pagination and metadata in a V2
rafaell-lycan opened this issue · 3 comments
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....
}
}
Two questions:
- What kind of extra filters do you have in mind?
- Can you give me an example for the pagination data that can be returned?
Thanks!
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.
@cheeaun it makes sense for you?