# new RamPaginator()
Extends the base Paginator class to provide pagination functionality for RAM adapter queries. This class handles the pagination of query results from the in-memory storage, allowing for efficient retrieval of large result sets in smaller chunks.
RAM-specific paginator implementation
Example
```typescript
// Create a query for User model
const query: RawRamQuery<User> = {
select: undefined, // Select all fields
from: User,
where: (user) => user.active === true
};
// Create a paginator with page size of 10
const paginator = new RamPaginator<User, User>(adapter, query, 10, User);
// Get the first page of results
const firstPage = await paginator.page(1);
// Get the next page
const secondPage = await paginator.page(2);
```
Methods
# async page(pageopt) → {Promise.<Array.<R>>}
Executes the query with pagination parameters to retrieve a specific page of results. This method calculates the appropriate skip value based on the page number and page size, executes the query, and updates the current page tracking.
Retrieves a specific page of results
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
page |
number
|
<optional> |
1 | The page number to retrieve (1-based) |
A promise that resolves to an array of results for the requested page
Promise.<Array.<R>>
# protected prepare(rawStatement) → {RawRamQuery.<M>}
Modifies the raw query statement to include pagination parameters. This protected method sets the limit parameter on the query to match the page size.
Prepares a RAM query for pagination
Parameters:
Name | Type | Description |
---|---|---|
rawStatement |
RawRamQuery.<M>
|
The original query statement |
The modified query with pagination parameters
RawRamQuery.<M>