All Projects → vapor-community → pagination

vapor-community / pagination

Licence: MIT License
Simple Vapor 3 Pagination

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to pagination

Fluent Sqlite Driver
Fluent driver for SQLite
Stars: ✭ 51 (-20.31%)
Mutual labels:  vapor, fluent
fluent-mysql-driver
🖋🐬 Swift ORM (queries, models, relations, etc) built on MySQL.
Stars: ✭ 69 (+7.81%)
Mutual labels:  vapor, fluent
Fluent Kit
Swift ORM (queries, models, and relations) for NoSQL and SQL databases
Stars: ✭ 82 (+28.13%)
Mutual labels:  vapor, fluent
flash
Flash messages between views ⚡️
Stars: ✭ 34 (-46.87%)
Mutual labels:  vapor, vapor-3
VaporElasticsearch
A Vapor/Swift Elasticsearch client
Stars: ✭ 26 (-59.37%)
Mutual labels:  vapor, vapor-3
apns
Vapor APNS for iOS
Stars: ✭ 59 (-7.81%)
Mutual labels:  vapor, vapor-3
paginator
Offset pagination for Vapor 🗂
Stars: ✭ 67 (+4.69%)
Mutual labels:  vapor, fluent
fluent-postgres-driver
🐘 PostgreSQL driver for Fluent.
Stars: ✭ 120 (+87.5%)
Mutual labels:  vapor, fluent
ferno
Vapor Firebase Realtime database provider
Stars: ✭ 52 (-18.75%)
Mutual labels:  vapor, vapor-3
submissions
Provides a common structure to deal with data based API requests
Stars: ✭ 15 (-76.56%)
Mutual labels:  vapor, vapor-3
mongo-driver
MongoDB driver for Fluent
Stars: ✭ 27 (-57.81%)
Mutual labels:  vapor, fluent
auth
👤 Authentication and Authorization framework for Fluent.
Stars: ✭ 51 (-20.31%)
Mutual labels:  vapor, fluent
gatekeeper
Rate limiting middleware for Vapor 👮
Stars: ✭ 54 (-15.62%)
Mutual labels:  vapor, vapor-3
FluentDNA
FluentDNA allows you to browse sequence data of any size using a zooming visualization similar to Google Maps. You can use FluentDNA as a standalone program or as a python module for your own bioinformatics projects.
Stars: ✭ 52 (-18.75%)
Mutual labels:  fluent
ExpectAnimXamarin
Xamarin.Android Binding, describe your animation and just run
Stars: ✭ 18 (-71.87%)
Mutual labels:  fluent
bugsnag
Report errors with Bugsnag 🐛
Stars: ✭ 37 (-42.19%)
Mutual labels:  vapor
sourcebans-web-theme-fluent
(Theme) Fluent theme for Sourcebans.
Stars: ✭ 22 (-65.62%)
Mutual labels:  fluent
SwiftString
A comprehensive, lightweight string extension for Swift 3.x & 4.0
Stars: ✭ 117 (+82.81%)
Mutual labels:  vapor
php-underscore
PHP underscore inspired &/or cloned from _.js, with extra goodies like higher order messaging
Stars: ✭ 42 (-34.37%)
Mutual labels:  fluent
Lingo
Powerful Swift string localization library with support for pluralization and string interpolation.
Stars: ✭ 55 (-14.06%)
Mutual labels:  vapor

Swift Vapor CircleCI

Vapor Pagination

Pagination is based off of the Fluent 2 pagination system.

Getting Started

Add this to your Package.swift file

.package(url: "https://github.com/vapor-community/pagination.git", from: "1.0.0")

Conform your model to Paginatable

extension MyModel: Paginatable { }

Once you have done that, it's as simple as returning your query in paginated format.

func test(_ req: Request) throws -> Future<Paginated<MyModel>> {
    return try MyModel.query(on: req).paginate(for: req)
}

Even return items off of the query builder

func test(_ req: Request) throws -> Future<Paginated<MyModel>> {
    return try MyModel.query(on: req).filter(\MyModel.name == "Test").paginate(for: req)
}

Making a request with the parameters is easy is appending ?page= and/or ?per=

curl "http://localhost:8080/api/v1/models?page=1&per=10"

A response looks like this

{
  "data": [{
    "updatedAt": "2018-03-07T00:00:00Z",
    "createdAt": "2018-03-07T00:00:00Z",
    "name": "My Test Model"
  }],
  "page": {
    "position": {
      "current": 1,
      "max": 1
    },
    "data": {
      "per": 10,
      "total": 2
    }
  }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].