Set.paginate()

Get the next or previous page of Set values that correspond to a previously acquired pagination token.

Signature

Set.paginate(cursor: String): Page<any>

Set.paginate(cursor: String, count: Number): Page<any>

Description

Set.paginate() gets the next or previous page of Set values that correspond to a previously acquired pagination token. Pagination tokens are provided when a Set is the last value in a query.

The page size can be set with the paginate() call, or accept the default number of paginated values: 16.

Parameters

Parameter Type Required Description

cursor

String

Yes

Encoded string representing a pagination cursor, a Base64-encoded object representing the state of a Set during pagination.

count

Number

Number of data items to return on the next page.

Return value

Type Description

Page

An object with:

- data: the page values as an Array - after: included where there is a subsequent page of values

Examples

  1. The page includes a pagination cursor:

    Letter.all() { letter }
    {
      data: [
        {
          letter: "A"
        },
        {
          letter: "B"
        },
        {
          letter: "C"
        },
    
          ... elided ...
    
        {
          letter: "U"
        },
        {
          letter: "V"
        },
        {
          letter: "W"
        }
      ],
      after: "hs+DzoPOg ... aY1hOohozrV7A"
    }
  2. Use the cursor to access the next page:

    Set.paginate("hs+DzoPOg ... aY1hOohozrV7A")
    {
      data: [
        {
          letter: "X"
        },
        {
          letter: "Y"
        },
        {
          letter: "Z"
        }
      ]
    }

See also

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!