Class: PageHelper

PageHelper(client, set, paramsnullable, optionsnullable)

new PageHelper(client, set, paramsnullable, optionsnullable)

A wrapper that provides a helpful API for consuming FaunaDB pages.

Generally this is constructed through the Client#paginate method.

The PageHelper#map and PageHelper#filter methods will wrap the underlying query with a Map and Filter query function, respectively. These will be executed on the server when a promise-returning function is called.

The PageHelper#each and PageHelper#eachReverse functions dispatch queries to FaunaDB, and return Promises representing the completion of those queries. The callbacks provided to these functions are executed locally when the queries return.

The PageHelper#nextPage and PageHelper#previousPage functions also dispatch queries to FaunaDB, but return their responses in a wrapped Promise.

Parameters:
Name Type Attributes Description
client Client

The FaunaDB client used to paginate.

set Object

The set to paginate.

params Object <nullable>

Parameters to be passed to the FaunaDB Paginate function.

options Object <nullable>

Object that configures the current pagination, overriding FaunaDB client options.

Properties
Name Type Attributes Description
secret string <nullable>

FaunaDB secret (see Reference Documentation)

Source:

Methods

each(lambda) → {external:Promise.<void>}

Executes the provided function for each page.

Parameters:
Name Type Description
lambda PageHelper~eachFunction

A function to be executed for each page.

Source:
Returns:
Type
external:Promise.<void>

eachReverse(lambda) → {external:Promise.<void>}

Executes the provided function for each page, in the reverse direction.

Parameters:
Name Type Description
lambda PageHelper~eachFunction
Source:
Returns:
Type
external:Promise.<void>

filter(lambda) → {PageHelper}

Wraps the set to be paginated with a FaunaDB Filter funciton. As this function is executed on the server, the lambda param must return a valid query expression.

Parameters:
Name Type Description
lambda PageHelper~collectionFunction

The lambda expression to be passed into the Filter function.

Source:
Returns:
Type
PageHelper

map(lambda) → {PageHelper}

Wraps the set to be paginated with a FaunaDB Map function. As this function is executed on the server, the lambda param must return a valid query expression.

Parameters:
Name Type Description
lambda PageHelper~collectionFunction

The Lambda expression to be passed into the Map function.

Source:
Returns:
Type
PageHelper

nextPage() → {external:Promise.<object>}

Queries for the next page from the current cursor point; this mutates the state of the PageHelper when the query completes, updating the internal cursor state to that of the returned page.

Source:
Returns:
Type
external:Promise.<object>

previousPage() → {external:Promise.<object>}

Queries for the previous page from the current cursor point; this mutates the state of the PageHelper when the query completes, updating the internal cursor state to that of the returned page.

Source:
Returns:
Type
external:Promise.<object>

Type Definitions

collectionFunction(var) → {Expr}

A FaunaDB Lambda expression to be passed into one of the collection functions: Map or Filter.

Parameters:
Name Type Description
var any

The variable passed in by FaunaDB when this Lambda function is executed.

Source:
Returns:

The FaunaDB query expression to be returned by this Lambda.

Type
Expr

eachFunction(page)

Parameters:
Name Type Description
page Object

A page returned by FaunaDB's Paginate function.

Source: