Set.paginate()

Get the next page of Set values.

Signature

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

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

Description

The Set.paginate() method gets the next page of Set values or count number of values using the after token received in the previous page.

The default page size of 16 can be changed using the paginate() method, in the range 1 to 16000.

The cursor is stable in the sense that pagination through a set is done for a fixed snapshot time, giving you a view of your data as it existed across the whole set at the instant you started paginating. For example, given set [a, b, c] when you start paginating, one item at a time, even if you delete item c after you started reading the set, item c is returned.

The exception is if the history is no longer available for the deleted item because history_days is set to the default value of 0 or is less than the minimum valid time needed. In that case, the deleted item is not returned with the paginated results and an error is returned:
Requested timestamp <time> less than minimum allowed timestamp..

A cursor is valid for history_days plus 15 minutes.

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 Set values to return in a page.

Return value

Type Description

Page

An object with:

data

Set values as an Array or page.

after

A cursor that is included when there are more pages available. The cursor is valid for history_days plus 15 minutes.

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!