BlyxDocumentation
Browse chapters
Documentation / Workflow recipes

Grebe · Resume a keyset page from its last emitted key

Build a repeatable keyset page and return the exact next cursor.

Resume a keyset page from its last emitted key

Offset pagination on changing data can repeat records. Validate the ordered key and return the final emitted key for the next request. A cursor between keys selects 20 and 30. Returning 30 lets the next page start at 40.

Run the framework with your own input

Install Blyx 0.2.1 and a Rust toolchain with a host linker, then run the versioned project. Each positional argument is a number or a comma-separated numerical vector. The CLI accepts up to 16 entries per vector. The imported module accepts longer inputs.

git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-grebe.git
cd blyx-grebe
blyxc native-run project.blyx -- "10,20,30,40" 15 2

API and return values

Returns [first index, exclusive end, resume key, has more]. On an empty result the input cursor is retained. Supply stable unique numeric keys from a consistent snapshot. Invalid input returns an empty vector.

ArgumentAccepted input
keysVector of: exact signed integer
cursorexact signed integer
sizepositive exact integer

Use the libraries independently

The framework vendors the same library source published in these two repositories. Each module has its own package page, input contract and regression suite.

Try the program

Output Ready
Expected output
1
3
30
1
Open in the full playground →

Practice

Change keys = [1, 2], cursor = 3.0. Predict the result, then run the program.

Hint

Returns [first index, exclusive end, resume key, has more]. On an empty result the input cursor is retained. Supply stable unique numeric keys from a consistent snapshot.

Worked solution

The result vector is [2, 2, 3, 0]. Compare its fields with the return layout in the API section.

Find

    let keys = [10, 20, 30, 40];

Replace with

    let keys = [1, 2];

Find

    let cursor = 15.0;

Replace with

    let cursor = 3.0;

Output after the change

2
2
3
0