import { Collection } from "mongodb"; import { ObjectID } from "bson"; 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; /** 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 fields to include in pages. */ fields(fields: { [field in keyof M]?: 1 | 0 | boolean; }): Pager; /** * Loads a page of records. * @param id the id of the page to load, if null then the first page is loaded. */ load(id?: ObjectID): 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 id to load the next page of records. * This will be null if this is the last page. */ nextId?: ObjectID; }