Comments (4)
@belkhadir When using the pagination method, the best way to handle custom sorts is to pass them into the pagination
function. You'll want to do something more of
func getNews(_ req: Request) throws -> Future<Paginated<Article>> {
return try Article.query(on: req).paginate(for: req, [(\Article.publishedAt).querySort()])
}
The way things are setup is you have to specify the sorts manually. I have to still look into a way of using the query builders sort method to return things
from pagination.
Do you have any documentation ?
from pagination.
@anthonycastelli this still doesn't work. Instead it returns a Future<Page
> and not a Future<Paginated>.from pagination.
@Prince2k3 I'm a bit late but maybe for those in the future.
I was wondering the same but you can see that in QueryBuilder+Paginatable.swift that the Page is mapped.
extension QueryBuilder where Result: Paginatable & Content, Result.Database == Database {
/// Returns a paginated response using page number from the request data
public func paginate(for req: Request) throws -> Future<Paginated<Result>> {
return try self.paginate(for: req).map(to: Paginated<Result>.self) { $0.response() }
}
}
The response() method converts it to Paginated.
hope it helps
from pagination.
Related Issues (17)
- Order of paginated results HOT 3
- Transform Closures (Or something like that) HOT 2
- Support for `join`/`alsoDecode` HOT 4
- License information HOT 7
- Is there a way to customize the response format? HOT 1
- Support database connection HOT 2
- Different sorting for different endpoint HOT 6
- Fluent filters are missing HOT 10
- Documentation
- Get all per page HOT 1
- Paginate non model objects
- Incorrect page total when filtering db and adding pagination
- Pagination fails when sorting
- Always return 1 as the max number of pages HOT 1
- Update documentation for size use HOT 1
- Public vars? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pagination.