Comments (6)
ToIf you're gonna override at the model level, it'll be something like this
extension MyModel: Paginatable {
static var defaultPageSorts: [MyModel.Database.QuerySort] {
return [
// Option #1
MyModel.Database.querySort(MyModel.Database.queryField(.keyPath(\ MyModel.name)), MyModel Database.querySortDirectionDescending),
// Option #2
(\MyModel.name).querySort()
]
}
}
If you want to do it on a route level, it'll be done something like this:
return try query.paginate(for: req, [(\Allergy.name).querySort()])
from pagination.
I'm gonna go ahead and close this issue, but if you do run into issues, feel free to reopen this. 🙂
from pagination.
Overriding the defaultPageSorts
will allow you to accomplish this on a per model basis.
If you want to do it on the fly, you can add your own sorts into the paginate method.
from pagination.
@anthonycastelli I want to sort with Boolean value from certain column. Could you show me some example?
from pagination.
@anthonycastelli thanks for the help. I would try that later
from pagination.
return try query.paginate(for: req, [(\Allergy.name).querySort()])
says Use of unresolved identifier 'query'.
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
- Fluent filters are missing HOT 10
- The pagination fails to work with groupBy and sort HOT 4
- 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.