Giter VIP home page Giter VIP logo

Comments (4)

anthonycastelli avatar anthonycastelli commented on May 24, 2024

@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.

belkhadir avatar belkhadir commented on May 24, 2024

Do you have any documentation ?

from pagination.

Prince2k3 avatar Prince2k3 commented on May 24, 2024

@anthonycastelli this still doesn't work. Instead it returns a Future<Page

> and not a Future<Paginated>.

from pagination.

shearos avatar shearos commented on May 24, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.