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 #68 from nodes-vapor/hotfix/fix-docs
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
steffendsommer authored Apr 15, 2019
2 parents e8e07bb + 820acaf commit e09e2af
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,18 @@ Note: the count query is expected to have a result with one column named `count`
To use Paginator together with Leaf, you can do the following:

```swift
struct GalaxyList: Codable {
let galaxies: [Galaxy]
}

router.get("galaxies") { (req: Request) -> Response in
let paginator: Future<OffsetPaginator<Galaxy>> = Galaxy.query(on: req).paginate(on: req)
return paginator.flatMap(to: Response.self) { paginator in
return try req.view().render(
"MyLeafFile",
GalaxyList(galaxies: paginator.data ?? []),
userInfo: try paginator.userInfo()
"MyLeafFile",
GalaxyList(galaxies: paginator.data ?? []),
userInfo: try paginator.userInfo(),
on: req
)
.encode(for: req)
}
Expand Down

0 comments on commit e09e2af

Please sign in to comment.