import { Collection } from "mongodb"; import Base from "./models/base"; /** A pager allows paging through a collection of records. */ export default class Pager { /** The collection to page through. */ readonly collection: Collection; /** The maximum number of records on a single page. */ private maxPageSize; /** The query that defines the dataset to load. */ private _query; /** The fields to return in the results. */ private _fields; /** The sorting method for the results */ private _sort; /** Construct given the collection, query and fields. */ constructor(collection: Collection); /** Sets the query to use for this pager. */ query(query: { [field: string]: any; }): Pager; /** Sets the sorting for this pager (make sure you use the same sorting for all pages). */ sort(sort: any): Pager; /** Sets the fields to include in pages. */ fields(fields: { [field in keyof M]?: 1 | 0 | boolean; }): Pager; /** * Loads a page of records. * @param pageIndex the 0 based index of the page to load */ load(pageIndex?: number): Promise>; } /** The default page size. */ export declare const DEFAULT_PAGE_SIZE = 30; /** A single page of records. */ export interface Page { /** The records on this page. */ records: M[]; /** * The index of the next page to load. * This will be null if this is the last page. */ nextId?: number; }