Open Cellane opened 6 years ago
I've not given this much thought as it's not crossed my mind, however, I do see how this would be a need for some people. I'll look into implementing something like this, but if you do have any ideas, feel free to submit PR
I think this would be a very welcoming addition. Personally, I have an example of a /feed
route that should return a heterogeneous array of feed items with different types.
If we had support for something like @Cellane proposes, then we don't have to do a weird dance of type erasure in order to support decoding/encoding of that heterogeneous array and instead rely on the multi-type pagination to return a result including a separate array for every type.
Just wanted to circle back to these issues and say I haven't forgotten about them. Just been swamped lately so haven't had a chance to work on anything regarding these packages. 🙂
Any progress here?
Motivation Behind Feature
At this moment, unless I’m mistaken, Pagination needs to operate on a
QueryBuilder
that producesFuture<[Model]>
. That makes it unable to paginate results that also fetch data from a different table, by using the Fluent’sjoin(_:to:)
/alsoDecode(_:)
methods, as these change the eventual output ofQueryBuilder
toFuture<[(ModelA, ModelB)]>
.Feature Description
It would be awesome if we could paginate even these slightly more complicated queries. I get a feeling that the eventual implementation would have to also rely on an implementation of #11 that would allow us to specify how should the end result be joined for a valid JSON representation.
Alternatives or Workarounds
None considered or thought of.