Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce paging for functions which returns list #6

Open
djordjedjukic opened this issue Mar 9, 2024 · 0 comments
Open

Introduce paging for functions which returns list #6

djordjedjukic opened this issue Mar 9, 2024 · 0 comments
Assignees

Comments

@djordjedjukic
Copy link
Owner

    let pageItems pageSize pageIndex items =
        let totalItems = Seq.length items
        let totalPages = (totalItems + pageSize - 1) / pageSize
        let pagedItems =
            items
            |> Seq.skip (pageIndex * pageSize)
            |> Seq.take pageSize
            |> Seq.toList // Convert to list here if necessary, or adjust return type to seq<'T> if keeping as sequence is preferred
        { Items = pagedItems; TotalItems = totalItems; TotalPages = totalPages }
type PagedResult<'T> = {
    Items: 'T list
    TotalItems: int
    TotalPages: int
}
@djordjedjukic djordjedjukic self-assigned this Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant