Skip to main content

Pagination

Retrieves a paginated list of keys matching a pattern.

  • Parameters:
    • limit: The maximum number of keys to return per page.
    • page: The page number to retrieve (1-based index).
    • pattern: Optional SQL LIKE pattern to match keys. Defaults to "%" which matches all keys.
  • Returns:
    • The result of the operation, includes an array of keys that match the pattern or an error if the operation failed.
// Get the first 5 keys from the database with result type handling
const result = db.pagination(5, 1);
if (result.success) {
console.log(result.data);
} else {
console.log(result.error.message);
}

// Get the first 5 keys from the database
const firstPage = db.pagination(5, 1);

// Get the first 10 keys with pattern
const firstUsersPage = db.pagination(10, 1, "user:%");

// Get the next 10 keys with pattern
const secondUsersPage = db.pagination(10, 2, "user:%");