WorkOS.Page (WorkOS SDK for Elixir v3.0.1)

Copy Markdown View Source

A single page of results with lazy auto-pagination.

Use WorkOS.Page.stream/1 to lazily iterate every item across all pages.

Summary

Functions

The cursor for the next page, or nil when this is the last page.

Whether another page is available.

Lazily streams every item across all pages, fetching pages on demand.

Types

t(item)

@type t(item) :: %WorkOS.Page{
  data: [item],
  fetch_next: (String.t() -> {:ok, t(item)} | {:error, term()}) | nil,
  list_metadata: map() | nil
}

Functions

after_cursor(page)

@spec after_cursor(t(term())) :: String.t() | nil

The cursor for the next page, or nil when this is the last page.

has_more?(page)

@spec has_more?(t(term())) :: boolean()

Whether another page is available.

stream(page)

@spec stream(t(item)) :: Enumerable.t() when item: term()

Lazily streams every item across all pages, fetching pages on demand.

Stops if a page fetch fails; use explicit pagination when you need to distinguish errors from the end of the collection.