Skip to content

Paginate

Information
Type Data Function
Namespace moxlib:api/data/paginate
Versions 1.15+

Overview

Groups records in target based on the size of count. Returns the grouped records based on the value of page.

Use Calculate Pages to calculate the amount of pages target has.

Example

In this example, there are nine records in target. The amount of records per page, count, is set to 3, and the page number itself, page, is 2. As such, it returns an output of[4,5,6].

data modify storage moxlib:api/data/paginate target set value [1,2,3,4,5,6,7,8,9]
data modify storage moxlib:api/data/paginate count set value 3
data modify storage moxlib:api/data/paginate page set value 2
function moxlib:api/data/paginate
Output of storage moxlib:api/data/paginate
{
  output: [4,5,6]
}
If page was 1, output would be [1,2,3], and if it was 3, output would be [7,8,9].

If count was 4, output would be [5,6,7,8].

API

Expects

Returns

The given page of target.