Skip to content

Releases: studio-falkland/vapor-pagination

Release list

v1.1.0

Choose a tag to compare

@leinelissen leinelissen released this 27 Jul 16:17
6cf43bb

Added

  • CursorPaginatedResponse<Element> — a Content-conforming wrapper
    around CursorPaginator that renders a JSON envelope with data,
    links, and meta keys.

  • CursorPaginator.makeResponse() -> CursorPaginatedResponse<Element>
    converts a paginator into a response with the same element type. Use it
    when you want a structured JSON response instead of returning the
    paginator directly.

  • CursorPaginator.responding(with:) -> CursorPaginatedResponse<T>
    maps paginated items through a transform closure and returns a response
    with a different element type. This is the recommended way to return
    paginated results when your route uses a DTO instead of the raw model.
    Cursor metadata — links, hasMore, cursor strings — is derived from the
    model-level paginator and is unaffected by the transform.

Example

app.get("users") { req -> CursorPaginatedResponse<UserResponse> in
    try await User.query(on: req.db)
        .sort(\.$id)
        .cursorPaginate(perPage: 20, on: req)
        .responding { user in
            UserResponse(id: user.id, displayName: user.name.capitalized)
        }
}

v1.0.0

Choose a tag to compare

@leinelissen leinelissen released this 27 Jul 15:37
214ab07

Initial release!