UNPKG

@typegoose/typegoose

Version:

Define Mongoose models using TypeScript classes

211 lines (210 loc) 22.9 kB
/// <reference types="mongoose/types/aggregate" /> /// <reference types="mongoose/types/callback" /> /// <reference types="mongoose/types/collection" /> /// <reference types="mongoose/types/connection" /> /// <reference types="mongoose/types/cursor" /> /// <reference types="mongoose/types/document" /> /// <reference types="mongoose/types/error" /> /// <reference types="mongoose/types/expressions" /> /// <reference types="mongoose/types/helpers" /> /// <reference types="mongoose/types/middlewares" /> /// <reference types="mongoose/types/indexes" /> /// <reference types="mongoose/types/models" /> /// <reference types="mongoose/types/mongooseoptions" /> /// <reference types="mongoose/types/pipelinestage" /> /// <reference types="mongoose/types/populate" /> /// <reference types="mongoose/types/query" /> /// <reference types="mongoose/types/schemaoptions" /> /// <reference types="mongoose/types/session" /> /// <reference types="mongoose/types/types" /> /// <reference types="mongoose/types/utility" /> /// <reference types="mongoose/types/validation" /> /// <reference types="mongoose/types/virtuals" /> /// <reference types="mongoose/types/schematypes" /> /// <reference types="mongoose/types/inferschematype" /> /// <reference types="mongoose/types/inferrawdoctype" /> import type { Aggregate, AggregateExtract, CallbackError, Document, MongooseQueryOrDocumentMiddleware, ErrorHandlingMiddlewareFunction, HydratedDocument, Model, MongooseDocumentMiddleware, MongooseQueryMiddleware, PostMiddlewareFunction, PreMiddlewareFunction, PreSaveMiddlewareFunction, Query, SchemaPostOptions, SchemaPreOptions, MongooseDistinctDocumentMiddleware, MongooseDefaultQueryMiddleware, MongooseDistinctQueryMiddleware, MongooseQueryAndDocumentMiddleware, InsertManyOptions } from 'mongoose'; import type { AnyParamConstructor, DocumentType, ReturnModelType } from './types'; /** Type copied from mongoose, because it is not exported but used in hooks */ type QueryResultType<T> = T extends Query<infer ResultType, any> ? ResultType : never; export declare const pre: { <S extends never, T = S>(method: 'save', fn: PreSaveMiddlewareFunction<T>, options?: SchemaPreOptions & { document: false; query: boolean; }): ClassDecorator; <S_1 extends never, T_1 = S_1>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: PreMiddlewareFunction<T_1>, options?: SchemaPreOptions & { document: false; query: false; }): ClassDecorator; <S_2 extends never, T_2 = S_2>(method: MongooseDistinctQueryMiddleware | MongooseDistinctQueryMiddleware[], fn: PreMiddlewareFunction<T_2>, options?: SchemaPreOptions & { document: boolean; query: false; }): ClassDecorator; <S_3 extends never, T_3 = S_3>(method: MongooseDistinctDocumentMiddleware | MongooseDistinctDocumentMiddleware[] | RegExp, fn: PreMiddlewareFunction<T_3>, options?: SchemaPreOptions & { document: false; query: boolean; }): ClassDecorator; <S_4 extends unknown, T_4 = S_4 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_4 : S_4 extends Document<unknown, any, any, Record<string, any>> ? S_4 : HydratedDocument<DocumentType<S_4>, any>>(method: MongooseQueryAndDocumentMiddleware | MongooseQueryAndDocumentMiddleware[] | RegExp, fn: PreMiddlewareFunction<T_4>, options?: SchemaPreOptions & { document: true; query: true; }): ClassDecorator; <S_5 extends unknown, T_5 = S_5 extends Document<unknown, any, any, Record<string, any>> ? S_5 : HydratedDocument<DocumentType<S_5>, any>>(method: 'save', fn: PreSaveMiddlewareFunction<T_5>, options?: SchemaPreOptions): ClassDecorator; <S_6 extends unknown, RawDocType = unknown>(method: 'init', fn: (this: S_6, doc: RawDocType) => void): ClassDecorator; <S_7 extends unknown, T_6 = S_7 extends Document<unknown, any, any, Record<string, any>> ? S_7 : HydratedDocument<DocumentType<S_7>, any>>(method: MongooseDistinctDocumentMiddleware | MongooseDistinctDocumentMiddleware[], fn: PreMiddlewareFunction<T_6>, options?: SchemaPreOptions): ClassDecorator; <S_8 extends unknown, T_7 = S_8 extends Document<unknown, any, any, Record<string, any>> ? S_8 : HydratedDocument<DocumentType<S_8>, any>>(method: MongooseQueryAndDocumentMiddleware | MongooseQueryAndDocumentMiddleware[] | RegExp, fn: PreMiddlewareFunction<T_7>, options?: SchemaPreOptions & { document: true; }): ClassDecorator; <S_9 extends unknown, T_8 = S_9 extends Document<unknown, any, any, Record<string, any>> ? S_9 : HydratedDocument<DocumentType<S_9>, any>>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: PreMiddlewareFunction<T_8>, options?: SchemaPreOptions & { document: true; query: false; }): ClassDecorator; <S_10 extends object | Query<any, any, {}, unknown, "find", Record<string, never>>, T_9 = S_10 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_10 : Query<DocumentType<S_10>, DocumentType<S_10>, {}, unknown, "find", Record<string, never>>>(method: MongooseDefaultQueryMiddleware | MongooseDefaultQueryMiddleware[], fn: PreMiddlewareFunction<T_9>): ClassDecorator; <S_11 extends object | Query<any, any, {}, unknown, "find", Record<string, never>>, T_10 = S_11 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_11 : Query<DocumentType<S_11>, DocumentType<S_11>, {}, unknown, "find", Record<string, never>>>(method: MongooseDistinctQueryMiddleware | MongooseDistinctQueryMiddleware[], fn: PreMiddlewareFunction<T_10>, options?: SchemaPreOptions): ClassDecorator; <S_12 extends object | Query<any, any, {}, unknown, "find", Record<string, never>>, T_11 = S_12 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_12 : Query<DocumentType<S_12>, DocumentType<S_12>, {}, unknown, "find", Record<string, never>>>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: PreMiddlewareFunction<T_11>, options?: SchemaPreOptions & { document: false; query: true; }): ClassDecorator; <S_13 extends unknown, T_12 = S_13 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_13 : S_13 extends Document<unknown, any, any, Record<string, any>> ? S_13 : HydratedDocument<DocumentType<S_13>, any>>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: PreMiddlewareFunction<T_12>, options?: SchemaPreOptions & { document: true; query: true; }): ClassDecorator; <T_13 extends Aggregate<any>>(method: 'aggregate' | RegExp, fn: PreMiddlewareFunction<T_13>, options?: SchemaPreOptions): ClassDecorator; <S_14 extends Model<any, {}, {}, {}, any, any> | AnyParamConstructor<any>, T_14 = S_14 extends Model<any, {}, {}, {}, any, any> ? S_14 : ReturnModelType<S_14>>(method: 'insertMany' | RegExp, fn: (this: T_14, next: (err?: CallbackError) => void, docs: any | Array<any>, options?: InsertManyOptions & { lean?: boolean; }) => void | Promise<void>, options?: SchemaPreOptions): ClassDecorator; }; export declare const post: { <S extends object | Query<any, any, {}, unknown, "find", Record<string, never>>, T = S extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S : Query<DocumentType<S>, DocumentType<S>, {}, unknown, "find", Record<string, never>>>(method: MongooseQueryMiddleware | MongooseQueryMiddleware[] | RegExp, fn: ErrorHandlingMiddlewareFunction<T>, options: SchemaPostOptions & { errorHandler: true; }): ClassDecorator; <S_1 extends unknown, T_1 = S_1 extends Document<unknown, any, any, Record<string, any>> ? S_1 : HydratedDocument<DocumentType<S_1>, any>>(method: MongooseDocumentMiddleware | MongooseDocumentMiddleware[] | RegExp, fn: ErrorHandlingMiddlewareFunction<T_1>, options: SchemaPostOptions & { errorHandler: true; }): ClassDecorator; <T_2 extends Aggregate<any>>(method: 'aggregate' | RegExp, fn: ErrorHandlingMiddlewareFunction<T_2, any[]>, options: SchemaPostOptions & { errorHandler: true; }): ClassDecorator; <S_2 extends Model<any, {}, {}, {}, any, any> | AnyParamConstructor<any>, T_3 = S_2 extends Model<any, {}, {}, {}, any, any> ? S_2 : ReturnModelType<S_2>>(method: 'insertMany' | RegExp, fn: ErrorHandlingMiddlewareFunction<T_3>, options: SchemaPostOptions & { errorHandler: true; }): ClassDecorator; <S_3 extends never, T_4 = S_3>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: PostMiddlewareFunction<T_4, T_4>, options?: SchemaPostOptions & { document: false; query: false; }): ClassDecorator; <S_4 extends never, T_5 = S_4>(method: MongooseDistinctQueryMiddleware | MongooseDistinctQueryMiddleware[], fn: PostMiddlewareFunction<T_5, T_5>, options?: SchemaPostOptions & { document: boolean; query: false; }): ClassDecorator; <S_5 extends never, T_6 = S_5>(method: MongooseDistinctDocumentMiddleware | MongooseDistinctDocumentMiddleware[], fn: PostMiddlewareFunction<T_6, T_6>, options?: SchemaPostOptions & { document: false; query: true; }): ClassDecorator; <S_6 extends unknown, T_7 = S_6 extends Document<unknown, any, any, Record<string, any>> ? S_6 : HydratedDocument<DocumentType<S_6>, any>>(method: MongooseDistinctDocumentMiddleware | MongooseDistinctDocumentMiddleware[], fn: PostMiddlewareFunction<T_7, T_7>, options?: SchemaPostOptions): ClassDecorator; <S_7 extends unknown, T_8 = S_7 extends Document<unknown, any, any, Record<string, any>> ? S_7 : HydratedDocument<DocumentType<S_7>, any>>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: PostMiddlewareFunction<T_8, T_8>, options?: SchemaPostOptions & { document: true; query: false; }): ClassDecorator; <S_8 extends unknown, T_9 = S_8 extends Document<unknown, any, any, Record<string, any>> ? S_8 : HydratedDocument<DocumentType<S_8>, any>>(method: 'init', fn: PostMiddlewareFunction<T_9, T_9>): ClassDecorator; <S_9 extends object | Query<any, any, {}, unknown, "find", Record<string, never>>, T_10 = S_9 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_9 : Query<DocumentType<S_9>, DocumentType<S_9>, {}, unknown, "find", Record<string, never>>>(method: MongooseDefaultQueryMiddleware | MongooseDefaultQueryMiddleware[], fn: PostMiddlewareFunction<T_10, QueryResultType<T_10>>): ClassDecorator; <S_10 extends object | Query<any, any, {}, unknown, "find", Record<string, never>>, T_11 = S_10 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_10 : Query<DocumentType<S_10>, DocumentType<S_10>, {}, unknown, "find", Record<string, never>>>(method: MongooseDistinctQueryMiddleware | MongooseDistinctQueryMiddleware[], fn: PostMiddlewareFunction<T_11, QueryResultType<T_11>>, options?: SchemaPostOptions): ClassDecorator; <S_11 extends object | Query<any, any, {}, unknown, "find", Record<string, never>>, T_12 = S_11 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_11 : Query<DocumentType<S_11>, DocumentType<S_11>, {}, unknown, "find", Record<string, never>>>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: PostMiddlewareFunction<T_12, QueryResultType<T_12>>, options?: SchemaPostOptions & { document: false; query: true; }): ClassDecorator; <S_12 extends unknown, T_13 = S_12 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_12 : S_12 extends Document<unknown, any, any, Record<string, any>> ? S_12 : HydratedDocument<DocumentType<S_12>, any>>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: ErrorHandlingMiddlewareFunction<T_13>, options?: SchemaPostOptions & { document: true; query: true; }): ClassDecorator; <T_14 extends Aggregate<any>>(method: 'aggregate' | RegExp, fn: PostMiddlewareFunction<T_14, AggregateExtract<T_14>[]>, options?: SchemaPostOptions): ClassDecorator; <S_13 extends Model<any, {}, {}, {}, any, any> | AnyParamConstructor<any>, T_15 = S_13 extends Model<any, {}, {}, {}, any, any> ? S_13 : ReturnModelType<S_13>>(method: 'insertMany' | RegExp, fn: PostMiddlewareFunction<T_15, T_15>, options?: SchemaPostOptions): ClassDecorator; }; export declare const Pre: { <S extends never, T = S>(method: 'save', fn: PreSaveMiddlewareFunction<T>, options?: SchemaPreOptions & { document: false; query: boolean; }): ClassDecorator; <S_1 extends never, T_1 = S_1>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: PreMiddlewareFunction<T_1>, options?: SchemaPreOptions & { document: false; query: false; }): ClassDecorator; <S_2 extends never, T_2 = S_2>(method: MongooseDistinctQueryMiddleware | MongooseDistinctQueryMiddleware[], fn: PreMiddlewareFunction<T_2>, options?: SchemaPreOptions & { document: boolean; query: false; }): ClassDecorator; <S_3 extends never, T_3 = S_3>(method: MongooseDistinctDocumentMiddleware | MongooseDistinctDocumentMiddleware[] | RegExp, fn: PreMiddlewareFunction<T_3>, options?: SchemaPreOptions & { document: false; query: boolean; }): ClassDecorator; <S_4 extends unknown, T_4 = S_4 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_4 : S_4 extends Document<unknown, any, any, Record<string, any>> ? S_4 : HydratedDocument<DocumentType<S_4>, any>>(method: MongooseQueryAndDocumentMiddleware | MongooseQueryAndDocumentMiddleware[] | RegExp, fn: PreMiddlewareFunction<T_4>, options?: SchemaPreOptions & { document: true; query: true; }): ClassDecorator; <S_5 extends unknown, T_5 = S_5 extends Document<unknown, any, any, Record<string, any>> ? S_5 : HydratedDocument<DocumentType<S_5>, any>>(method: 'save', fn: PreSaveMiddlewareFunction<T_5>, options?: SchemaPreOptions): ClassDecorator; <S_6 extends unknown, RawDocType = unknown>(method: 'init', fn: (this: S_6, doc: RawDocType) => void): ClassDecorator; <S_7 extends unknown, T_6 = S_7 extends Document<unknown, any, any, Record<string, any>> ? S_7 : HydratedDocument<DocumentType<S_7>, any>>(method: MongooseDistinctDocumentMiddleware | MongooseDistinctDocumentMiddleware[], fn: PreMiddlewareFunction<T_6>, options?: SchemaPreOptions): ClassDecorator; <S_8 extends unknown, T_7 = S_8 extends Document<unknown, any, any, Record<string, any>> ? S_8 : HydratedDocument<DocumentType<S_8>, any>>(method: MongooseQueryAndDocumentMiddleware | MongooseQueryAndDocumentMiddleware[] | RegExp, fn: PreMiddlewareFunction<T_7>, options?: SchemaPreOptions & { document: true; }): ClassDecorator; <S_9 extends unknown, T_8 = S_9 extends Document<unknown, any, any, Record<string, any>> ? S_9 : HydratedDocument<DocumentType<S_9>, any>>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: PreMiddlewareFunction<T_8>, options?: SchemaPreOptions & { document: true; query: false; }): ClassDecorator; <S_10 extends object | Query<any, any, {}, unknown, "find", Record<string, never>>, T_9 = S_10 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_10 : Query<DocumentType<S_10>, DocumentType<S_10>, {}, unknown, "find", Record<string, never>>>(method: MongooseDefaultQueryMiddleware | MongooseDefaultQueryMiddleware[], fn: PreMiddlewareFunction<T_9>): ClassDecorator; <S_11 extends object | Query<any, any, {}, unknown, "find", Record<string, never>>, T_10 = S_11 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_11 : Query<DocumentType<S_11>, DocumentType<S_11>, {}, unknown, "find", Record<string, never>>>(method: MongooseDistinctQueryMiddleware | MongooseDistinctQueryMiddleware[], fn: PreMiddlewareFunction<T_10>, options?: SchemaPreOptions): ClassDecorator; <S_12 extends object | Query<any, any, {}, unknown, "find", Record<string, never>>, T_11 = S_12 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_12 : Query<DocumentType<S_12>, DocumentType<S_12>, {}, unknown, "find", Record<string, never>>>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: PreMiddlewareFunction<T_11>, options?: SchemaPreOptions & { document: false; query: true; }): ClassDecorator; <S_13 extends unknown, T_12 = S_13 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_13 : S_13 extends Document<unknown, any, any, Record<string, any>> ? S_13 : HydratedDocument<DocumentType<S_13>, any>>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: PreMiddlewareFunction<T_12>, options?: SchemaPreOptions & { document: true; query: true; }): ClassDecorator; <T_13 extends Aggregate<any>>(method: 'aggregate' | RegExp, fn: PreMiddlewareFunction<T_13>, options?: SchemaPreOptions): ClassDecorator; <S_14 extends Model<any, {}, {}, {}, any, any> | AnyParamConstructor<any>, T_14 = S_14 extends Model<any, {}, {}, {}, any, any> ? S_14 : ReturnModelType<S_14>>(method: 'insertMany' | RegExp, fn: (this: T_14, next: (err?: CallbackError) => void, docs: any | Array<any>, options?: InsertManyOptions & { lean?: boolean; }) => void | Promise<void>, options?: SchemaPreOptions): ClassDecorator; }; export declare const Post: { <S extends object | Query<any, any, {}, unknown, "find", Record<string, never>>, T = S extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S : Query<DocumentType<S>, DocumentType<S>, {}, unknown, "find", Record<string, never>>>(method: MongooseQueryMiddleware | MongooseQueryMiddleware[] | RegExp, fn: ErrorHandlingMiddlewareFunction<T>, options: SchemaPostOptions & { errorHandler: true; }): ClassDecorator; <S_1 extends unknown, T_1 = S_1 extends Document<unknown, any, any, Record<string, any>> ? S_1 : HydratedDocument<DocumentType<S_1>, any>>(method: MongooseDocumentMiddleware | MongooseDocumentMiddleware[] | RegExp, fn: ErrorHandlingMiddlewareFunction<T_1>, options: SchemaPostOptions & { errorHandler: true; }): ClassDecorator; <T_2 extends Aggregate<any>>(method: 'aggregate' | RegExp, fn: ErrorHandlingMiddlewareFunction<T_2, any[]>, options: SchemaPostOptions & { errorHandler: true; }): ClassDecorator; <S_2 extends Model<any, {}, {}, {}, any, any> | AnyParamConstructor<any>, T_3 = S_2 extends Model<any, {}, {}, {}, any, any> ? S_2 : ReturnModelType<S_2>>(method: 'insertMany' | RegExp, fn: ErrorHandlingMiddlewareFunction<T_3>, options: SchemaPostOptions & { errorHandler: true; }): ClassDecorator; <S_3 extends never, T_4 = S_3>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: PostMiddlewareFunction<T_4, T_4>, options?: SchemaPostOptions & { document: false; query: false; }): ClassDecorator; <S_4 extends never, T_5 = S_4>(method: MongooseDistinctQueryMiddleware | MongooseDistinctQueryMiddleware[], fn: PostMiddlewareFunction<T_5, T_5>, options?: SchemaPostOptions & { document: boolean; query: false; }): ClassDecorator; <S_5 extends never, T_6 = S_5>(method: MongooseDistinctDocumentMiddleware | MongooseDistinctDocumentMiddleware[], fn: PostMiddlewareFunction<T_6, T_6>, options?: SchemaPostOptions & { document: false; query: true; }): ClassDecorator; <S_6 extends unknown, T_7 = S_6 extends Document<unknown, any, any, Record<string, any>> ? S_6 : HydratedDocument<DocumentType<S_6>, any>>(method: MongooseDistinctDocumentMiddleware | MongooseDistinctDocumentMiddleware[], fn: PostMiddlewareFunction<T_7, T_7>, options?: SchemaPostOptions): ClassDecorator; <S_7 extends unknown, T_8 = S_7 extends Document<unknown, any, any, Record<string, any>> ? S_7 : HydratedDocument<DocumentType<S_7>, any>>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: PostMiddlewareFunction<T_8, T_8>, options?: SchemaPostOptions & { document: true; query: false; }): ClassDecorator; <S_8 extends unknown, T_9 = S_8 extends Document<unknown, any, any, Record<string, any>> ? S_8 : HydratedDocument<DocumentType<S_8>, any>>(method: 'init', fn: PostMiddlewareFunction<T_9, T_9>): ClassDecorator; <S_9 extends object | Query<any, any, {}, unknown, "find", Record<string, never>>, T_10 = S_9 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_9 : Query<DocumentType<S_9>, DocumentType<S_9>, {}, unknown, "find", Record<string, never>>>(method: MongooseDefaultQueryMiddleware | MongooseDefaultQueryMiddleware[], fn: PostMiddlewareFunction<T_10, QueryResultType<T_10>>): ClassDecorator; <S_10 extends object | Query<any, any, {}, unknown, "find", Record<string, never>>, T_11 = S_10 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_10 : Query<DocumentType<S_10>, DocumentType<S_10>, {}, unknown, "find", Record<string, never>>>(method: MongooseDistinctQueryMiddleware | MongooseDistinctQueryMiddleware[], fn: PostMiddlewareFunction<T_11, QueryResultType<T_11>>, options?: SchemaPostOptions): ClassDecorator; <S_11 extends object | Query<any, any, {}, unknown, "find", Record<string, never>>, T_12 = S_11 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_11 : Query<DocumentType<S_11>, DocumentType<S_11>, {}, unknown, "find", Record<string, never>>>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: PostMiddlewareFunction<T_12, QueryResultType<T_12>>, options?: SchemaPostOptions & { document: false; query: true; }): ClassDecorator; <S_12 extends unknown, T_13 = S_12 extends Query<any, any, {}, unknown, "find", Record<string, never>> ? S_12 : S_12 extends Document<unknown, any, any, Record<string, any>> ? S_12 : HydratedDocument<DocumentType<S_12>, any>>(method: MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware[] | RegExp, fn: ErrorHandlingMiddlewareFunction<T_13>, options?: SchemaPostOptions & { document: true; query: true; }): ClassDecorator; <T_14 extends Aggregate<any>>(method: 'aggregate' | RegExp, fn: PostMiddlewareFunction<T_14, AggregateExtract<T_14>[]>, options?: SchemaPostOptions): ClassDecorator; <S_13 extends Model<any, {}, {}, {}, any, any> | AnyParamConstructor<any>, T_15 = S_13 extends Model<any, {}, {}, {}, any, any> ? S_13 : ReturnModelType<S_13>>(method: 'insertMany' | RegExp, fn: PostMiddlewareFunction<T_15, T_15>, options?: SchemaPostOptions): ClassDecorator; }; export {};