///
///
///
import { Model, PipelineStage, Query } from "mongoose";
import { DocumentType } from "@typegoose/typegoose";
/**
* The pagination options that can be passed.
*/
export interface IPaginateOptions {
limit?: number;
sortField?: string;
sortAscending?: Boolean;
next?: string;
previous?: string;
}
/**
* The result of the paginated find request
*/
export interface IPaginateResult {
hasNext?: boolean;
hasPrevious?: boolean;
next?: string;
previous?: string;
totalDocs: number;
docs: T[];
}
/**
* Verbosity mode for mongoDB's explain() function
*/
export type VerboseMode = "queryPlanner" | "executionStats" | "allPlansExecution";
/**
* An extension of the mongoose Model which include the findPaged method.
*/
export interface IPaginateModel extends Model, {}> {
findPaged(options: IPaginateOptions, query?: Object, projection?: Object, _populate?: (Object | string)[]): Query>, DocumentType>;
findPagedExplain(options: IPaginateOptions, verbose?: VerboseMode, _query?: Object, _projection?: Object): Promise;
aggregatePaged(options: IPaginateOptions, pipeline: PipelineStage[]): Query>, DocumentType>;
}
/**
* [Typegoose only] This is a type that you can cast your Typegoose model to
* Example: export const UserModel = new User().getModelForClass(User) as PaginateModel;
*/
export type PaginateModel = IPaginateModel> & T & T2;