# new CouchDBPaginator(adapter, query, size, clazz)
Implements pagination for CouchDB queries using bookmarks for efficient navigation through result sets
Paginator for CouchDB query results
Parameters:
Name | Type | Description |
---|---|---|
adapter |
CouchDBAdapter.<any, any, any>
|
The CouchDB adapter |
query |
MangoQuery
|
The Mango query to paginate |
size |
number
|
The page size |
clazz |
Constructor.<M>
|
The model constructor |
Example
// Example of using CouchDBPaginator
const adapter = new MyCouchDBAdapter(scope);
const query = { selector: { type: "user" } };
const paginator = new CouchDBPaginator(adapter, query, 10, User);
// Get the first page
const page1 = await paginator.page(1);
// Get the next page
const page2 = await paginator.page(2);
Classes
- CouchDBPaginator
Initializes a paginator for CouchDB query results
- CouchDBPaginator
Initializes a paginator for CouchDB query results
Members
Methods
# count() → {number}
Not supported in CouchDB - throws an error when accessed
Gets the total record count
Always throws as this functionality is not available in CouchDB
InternalError
Never returns as it throws an error
number
# async page(pageopt) → {Promise.<Array.<R>>}
Executes the query with pagination and processes the results
Retrieves a specific page of results
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
page |
number
|
<optional> |
1 | The page number to retrieve |
If trying to access a page other than the first without a bookmark, or if no class is defined
PagingError
A promise that resolves to an array of results
Promise.<Array.<R>>
# protected prepare(rawStatement) → {MangoQuery}
Modifies the raw query to include pagination parameters
Prepares a query for pagination
Parameters:
Name | Type | Description |
---|---|---|
rawStatement |
MangoQuery
|
The original Mango query |
The prepared query with pagination parameters
# total() → {number}
Not supported in CouchDB - throws an error when accessed
Gets the total number of pages
Always throws as this functionality is not available in CouchDB
InternalError
Never returns as it throws an error
number