Interface FindPage<T>

Overview

Represents a page of results returned by the Data API when using pagination in find operations.

This interface encapsulates all the information returned from a single page fetch, including the actual data fetched & mapped, the pagination state, and the sort vector if applicable.

✏️Note: This interface is primarily used with the FindCursor.initialPageState and FindCursor.fetchNextPage methods, which provide direct access to the underlying pagination mechanisms.

Example

// Server-side code
async function getPageOfResults(pageState?: string) {
const cursor = collection.find({ status: 'active' })
.initialPageState(pageState);

const page = await cursor.fetchNextPage();

return {
nextPageState: page.nextPageState,
results: page.result,
};
}

// Client can then use the nextPageState to fetch subsequent pages

See

  • FindCursor.initialPageState
  • FindCursor.fetchNextPage
interface FindPage<T> {
    nextPageState: null | string;
    result: T[];
    sortVector?: DataAPIVector;
}

Type Parameters

  • T

Properties

nextPageState: null | string

The state for the next page of results, which may be stored on the client side to drive pagination.

If this is null, there are no more results to fetch, and the client should stop paginating.

result: T[]

The records present in the find page, with any mappings applied.

sortVector?: DataAPIVector

The sort vector used to perform the vector search, if applicable.

This is only applicable when using vector search and FindCursor.includeSortVector is set to true, and will not be present otherwise.