Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #77 from nodes-vapor/feature/allow-specifying-pagi…
Browse files Browse the repository at this point in the history
…nator-type

Enable specifying paginator type
  • Loading branch information
siemensikkema authored Sep 4, 2019
2 parents 2e938c3 + 6418974 commit e3c8a74
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
12 changes: 8 additions & 4 deletions Sources/Paginator/Paginatable/ArrayPaginatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public extension ArrayPaginatable {

public extension Array where Iterator.Element: Codable {
func paginate<P: Paginator>(
for req: Request
for req: Request,
type: P.Type = P.self
) throws -> Future<P> where
P: ArrayPaginatable,
P.Object == Iterator.Element,
Expand All @@ -33,7 +34,8 @@ public extension Array where Iterator.Element: Codable {

func paginate<P: Paginator>(
count: Int,
for req: Request
for req: Request,
type: P.Type = P.self
) throws -> Future<P> where
P: ArrayPaginatable,
P.Object == Iterator.Element,
Expand All @@ -54,7 +56,8 @@ extension Array: Transformable where Iterator.Element: Codable {

public extension TransformingQuery {
func paginate<P: Paginator>(
for req: Request
for req: Request,
type: P.Type = P.self
) throws -> Future<P> where
P: ArrayPaginatable,
P.PaginatorMetaData == P.PaginatableMetaData,
Expand All @@ -66,7 +69,8 @@ public extension TransformingQuery {

func paginate<P: Paginator>(
count: Int,
for req: Request
for req: Request,
type: P.Type = P.self
) throws -> Future<P> where
P: ArrayPaginatable,
P.PaginatorMetaData == P.PaginatableMetaData,
Expand Down
12 changes: 8 additions & 4 deletions Sources/Paginator/Paginatable/QueryBuilderPaginatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public protocol QueryBuilderPaginatable: Paginatable {

public extension QueryBuilder {
func paginate<P: Paginator>(
for req: Request
for req: Request,
type: P.Type = P.self
) throws -> Future<P> where
P: QueryBuilderPaginatable,
P.Object == Result,
Expand All @@ -24,7 +25,8 @@ public extension QueryBuilder {

func paginate<P: Paginator>(
count: Future<Int>,
for req: Request
for req: Request,
type: P.Type = P.self
) throws -> Future<P> where
P: QueryBuilderPaginatable,
P.Object == Result,
Expand All @@ -41,7 +43,8 @@ extension QueryBuilder: Transformable {

public extension TransformingQuery {
func paginate<P: Paginator, T>(
for req: Request
for req: Request,
type: P.Type = P.self
) throws -> Future<P> where
T: QuerySupporting,
P: QueryBuilderPaginatable,
Expand All @@ -54,7 +57,8 @@ public extension TransformingQuery {

func paginate<P: Paginator, T>(
count: Future<Int>,
for req: Request
for req: Request,
type: P.Type = P.self
) throws -> Future<P> where
T: QuerySupporting,
P: QueryBuilderPaginatable,
Expand Down
12 changes: 8 additions & 4 deletions Sources/Paginator/Paginatable/RawSQLBuilderPaginatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public extension RawSQLBuilder {
}

func paginate<P: Paginator>(
for req: Request
for req: Request,
type: P.Type = P.self
) throws -> Future<P> where
P: RawSQLBuilderPaginatable,
P.Object == Result,
Expand All @@ -59,7 +60,8 @@ public extension RawSQLBuilder {

func paginate<P: Paginator>(
count: Future<Int>,
for req: Request
for req: Request,
type: P.Type = P.self
) throws -> Future<P> where
P: RawSQLBuilderPaginatable,
P.Object == Result,
Expand All @@ -79,7 +81,8 @@ extension RawSQLBuilder: Transformable {

public extension TransformingQuery {
func paginate<P: Paginator, Database>(
for req: Request
for req: Request,
type: P.Type = P.self
) throws -> Future<P> where
P: RawSQLBuilderPaginatable,
Query: RawSQLBuilder<Database, Result>,
Expand All @@ -91,7 +94,8 @@ public extension TransformingQuery {

func paginate<P: Paginator, Database>(
count: Future<Int>,
for req: Request
for req: Request,
type: P.Type = P.self
) throws -> Future<P> where
P: RawSQLBuilderPaginatable,
Query: RawSQLBuilder<Database, Result>,
Expand Down

0 comments on commit e3c8a74

Please sign in to comment.