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 #66 from nodes-vapor/feature/update-sugar
Browse files Browse the repository at this point in the history
Update Sugar
  • Loading branch information
siemensikkema authored Feb 8, 2019
2 parents dc9978d + a722339 commit 4703564
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/vapor/fluent.git", from: "3.0.0"),
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0"),
.package(url: "https://github.com/nodes-vapor/sugar.git", from: "3.0.0-beta"),
.package(url: "https://github.com/nodes-vapor/sugar.git", from: "4.0.0-beta"),
],
targets: [
.target(name: "Paginator", dependencies: ["Fluent", "Vapor", "Sugar"]),
Expand Down
5 changes: 2 additions & 3 deletions Sources/Paginator/Paginatable/ArrayPaginatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ public extension TransformingQuery {
count: count,
on: req
)
.flatMap { args -> Future<P> in
let (results, data) = args
return try self.transform(results).map { results in
.flatMap { results, data -> Future<P> in
try self.transform(results).map { results in
return try P(data: results, meta: data)
}
}
Expand Down
21 changes: 6 additions & 15 deletions Sources/Paginator/Paginatable/QueryBuilderPaginatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public extension QueryBuilder {
P.Object == Result,
P.PaginatorMetaData == P.PaginatableMetaData
{
return try self.paginate(count: self.count(), for: req)
return try paginate(count: count(), for: req)
}

public func paginate<P: Paginator>(
Expand All @@ -30,10 +30,7 @@ public extension QueryBuilder {
P.Object == Result,
P.PaginatorMetaData == P.PaginatableMetaData
{
return try P.paginate(source: self, count: count, on: req).map { args -> P in
let (results, data) = args
return try P(data: results, meta: data)
}
return try P.paginate(source: self, count: count, on: req).map(P.init)
}
}

Expand Down Expand Up @@ -65,16 +62,10 @@ public extension TransformingQuery {
TransformedResult == P.Object,
P.PaginatorMetaData == P.PaginatableMetaData
{
return try P.paginate(
source: self.source,
count: count,
on: req
)
.flatMap { args -> Future<P> in
let (results, data) = args
return try self.transform(results).map { results in
return try P(data: results, meta: data)
return try P
.paginate(source: self.source, count: count, on: req)
.flatMap { (results, metadata) -> Future<P> in
try self.transform(results).map { try P(data: $0, meta: metadata) }
}
}
}
}

0 comments on commit 4703564

Please sign in to comment.