Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Paginator<Params, ReturnType, TransformType>

A utility class to help paginate queries.

example
const paginator = user.getDocumentPaginator({
limit: 10 // fetch ten documents at a time
})

// Get the first ten documents
const firstTen = await paginator.next();

// Get the next ten documents
const nextTen = await paginator.next();

Type parameters

  • Params: PaginateParams

    Parameters for the paginator. Sets things like limit, sorting, pagination, etc

  • ReturnType

    The return type of the Paginator functions

  • TransformType = never

Hierarchy

  • Paginator

Index

Properties

Methods

Properties

fetched: Record<string, ReturnType>

A cache of all the items this Paginator has fetched.

The key is the ID of the entity, and the value is the entity itself

Methods

  • next(): Promise<TransformType extends never ? ReturnType[] : TransformType[]>
  • Gets the next set of items.

    Returns an array of entities assigned to this paginator. For example, if the paginator was created from User.getDocumentPaginator, this would return an array of [[Document]]

    If this function returns an empty array, it means there are no more results left

    Returns Promise<TransformType extends never ? ReturnType[] : TransformType[]>

Generated using TypeDoc